cypress: Cypress not able to load a different domain used in the second test
I have 2 tests. In one test the user goes to www.nordstromrack.com and login and in the second test case it goes to www.hautelook.com and tries to the same. Ideally the test should be able to navigate between 2 domains within the same test case but since that’s not possible in cypress so I had to add the second test case.
Current behavior:
In the first test case its able to successfully login but when it goes to the second test case then it tries to load the page and after a few seconds it shows the page not found .
If in test case 1 , I dont log in and if is imply go to nordstromrack.com and just click on login button and then move to second test case then it actually loads the hautelook.com page in the second test case .But when i include login step then it fails to load the second url in the second test.
Desired behavior:
Cypress should able to successfully open the second domain and proceed with the test.
Test code to reproduce
describe('My Second Test Suite', function () {
it('My FirstTest case', function () {
cy.visit("https://www.nordstromrack.com/")
cy.contains('Log In').click({ force: true })
cy.get('button:contains("Log In")').click()
cy.get('input[name="email"]:visible').clear().type("cypresstest@test.com")
cy.get('input[name="password"]').clear().type("Cypress@123")
cy.get('button:contains("Log In")').click()
cy.get('.modal-template__close-icon').click()
cy.get('.secondary-nav__name').should('have.text', 'tester')
cy.wait(3000)
})
it('My SecondTest case', function () {
cy.visit("https://www.hautelook.com/") //cypress not loading this page in second test case
cy.contains('Log In').click({ force: true })
cy.get('button:contains("Log In")').click()
cy.get('input[name="email"]:visible').clear().type("cypresstest@test.com")
cy.get('input[name="password"]').clear().type("Cypress@123")
cy.get('button:contains("Log In")').click()
cy.get('.secondary-nav__name').should('have.text', 'tester')
})
})
Versions
Cypress package version: 3.8.2 Cypress binary version: 3.8.2 Macbook Google Chrome :79
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (3 by maintainers)
I have gone through this documentation that’s why my 2 different domains are part of 2 separate tests. According to docs you cant have 2 different superdomains as a part of a single test.
I am afraid you won’t be hearing any good news anytime soon. Cypress fixes bugs as per their priority and this bug is not their priority.
Better move to Puppeteer or TestCafe for your demo
Odd thing is, if I replace cy.visit() with cy.request() I get the page I expect (I get the HTML back as a response) but cy.visit() prompts a “page not found”
@pranaydua1987 Pls read this documention: https://docs.cypress.io/guides/guides/web-security.html#Same-superdomain-per-test