0
votes

Some background: before loading my website I need to obtain an oauth token from a 3rd party provider. This requires visiting a new URL, entering in some test credentials, clicking sign-in, and then pulling the oauth token back. Once I have this oauth token I can then load our website and store it in localStorage and proceed with the test.

However, whenever I visit a page in cypress I then cannot visit any other domains or I receive a CORS error (seems this is intended by cypress). Is there any way to do this? Is there a way to visit a website one time before my tests run, login, and then run my tests?

1
Cypress does not support visiting different domains in one test. Instead of opening the page, use cy.request() to obtain needed token.Jonah
@Jonah's comment should be posted as an answer so that it can be accepted as an answer. It is definitely the right answer!Jonathan Tuzman
@JonathanTuzman added answerJonah

1 Answers

1
votes

Cypress does not support visiting different domains in one test. Instead of opening the page, use cy.request() to obtain needed token.

Further read: