I am a beginner in working with Cypress.
I am trying to build one test scenario for login.
I have this first url defined in cypress.json which is the page for signing in: "cozone_url": "https://idp-develop-devdb.staging.cozone.com/"
After successfully logging in, I am taken to the second page with URL: https://portal-develop-devdb.staging.cozone.com/ui/#/. In this page, I have one element which by clicking on it takes me to the actual application that I need to automate:
If I do not remove target attribute for the app element, the application opens correctly on a new child tab. I know that this is not handled with cypress so I tried to remove it:
And ('I Click on Azets Invoice icon', ()=> {
//this should open url https://invoice.test.azets.com/en
cy.get("a[data-test-application-identifier='EFLOW_INVOICES_V2']").invoke('removeAttr','target').click() })
A new tab is not opened, but the https://invoice.test.azets.com/en is not loaded in the original tab and I have this error: Refused to frame '' because it violates the following Content Security Policy directive: "frame-src
Also, when trying to go directly to the url with visit method I have this error:
The new URL is considered a different origin because the following parts of the URL are different
I know that this happens because of the security restrictions, that Cypress does not allow to change the domain within the same test, but how can I automate this scenario?
I login from url 1, then a page is opened where I have the link to my app and have to click on it and go to url2, which I am not allowed.
I tried to split this into 2 tests and use Cypress.Cookies.preserveOnce() method, but I don't know which cookie name I should preserve for the second test.
Do you have any idea on how should I automate the scenario using Cypress?
Try turning off web security to remove CORS restrictions.
In cypress.json add
{
"chromeWebSecurity": false
}
Ref: Web Security