Akshat
Akshat

Reputation: 91

cy.visit() failed because while attempting to visit a second unique domain/location/url in a single test case

I need to navigate two different urls in a single Test but when am navigating second one , it giving me error 1.FirstUrl- "https://app.ca-test.com/Public/Login?ReturnUrl=%2F" 2.SecondUrl -"https://www.mailinator.com/"(location and origin is change)

"cy.visit() failed because you are attempting to visit a URL that is of a different origin."

I used cy.request() also but didn't work so how can we do this?? But i have to navigate two urls in single test, and can not divide test case. This is my TestCase

Upvotes: 3

Views: 4724

Answers (1)

voy
voy

Reputation: 717

Cypress is preventing going cross origin since always forever. This was kinda covered in this question, but only kinda.

To sum up:

  • Different domains in one test are not officially supported, at least not yet. There is a whole section regarding this in the Cypress documentation

  • There is a feature request on their board to support more than one, but I don't see it being implemented anytime soon, there are some workarounds posted in that ticket, maybe one of them will work for you.

  • You could disable chrome cross-origin security by adding chromeWebSecurity: false to the cypress.json config file

  • If you want to use Mailinator to check/send emails, why do you have to visit the site? Just use their API and cy.request()

  • Never link your test environment directly here.

Upvotes: 2

Related Questions