Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
How to handle sign on with security restrictions in Cypress

I am a beginner in working with Cypress.

I am trying to build one test scenario for login.

  1. 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/"

  2. 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?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try turning off web security to remove CORS restrictions.

In cypress.json add

{ 
  "chromeWebSecurity": false
}

Ref: Web Security

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda