cypress: Cypress stuck in infinite redirect loop
EDIT: replicate this bug in a simpler website: cy.visit() to saucedemo.com using cypres open to run the test.
Current behavior
- cy.visit timeouts even when page is fully visible in the runner. URL is http://tutorialspoint.com/html/html_iframes.htm
Your page did not fire its load event within 60000ms
This timeout issue was reported by several people in stackoverflow without a solution. https://stackoverflow.com/questions/76186375/how-to-resolve-or-ignore-the-your-page-did-not-fire-its-load-event-error https://stackoverflow.com/questions/76591451/visiting-tutorialspoint-with-cypress-keeps-waiting-for-the-page-to-load
Some people report it in comments of other post to StackOverflow, and decide to quit Cypress altogether as a testing framework. Also here
Desired behavior
cy.visit('/http://tutorialspoint.com/html/html_iframes.htm');
or
baseURL: "http://tutorialspoint.com/html/html_iframes.htm" with cy.visit('/')
Should work at visiting the page, rendering it as experienced by an end user on chrome and allow me to continue to test the website.
Test code to reproduce
describe('Cypress interaction with Tutorialspoint', () => {
beforeEach(() => {
cy.visit('http://tutorialspoint.com/html/html_iframes.htm'); //FAILS HERE!!!!!
// cy.visit('/'); in case is set at baseURL
})
it('Performs tasks and logs results', () =>{
cy.contains('HTML - Iframes'); //THIS ASSERTION IS MEANINGLESS. READ THE DESCRIPTION.
})
})
Cypress Version
12.16.0
Node version
v18.16.1
Operating System
Ubuntu 22.04.2 LTS x86_64
Debug Logs
When cy visit, url: CypressError: Timed out after waiting `60000ms` for your remote page to load.
Your page did not fire its `load` event within `60000ms`.
You can try increasing the `pageLoadTimeout` value in `cypress.config.js` to wait longer.
Browsers will not fire the `load` event until all stylesheets and scripts are done downloading.
When this `load` event occurs, Cypress will continue running commands.
Other
selecting https in the URL works the same way as withouth
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 37 (21 by maintainers)
I diagnosed the problem. One of hundreds of JavaScript resources loaded by this website has an infinite redirect. Opening the website in a regular browser seems to be okay; the redirect still happens, but the browser recognises the loop and terminates it.
Here’s the error in my console (not Cypress, just Chrome). Note ERR_TOO_MANY_REDIRECTS.
I did
cy.visit()in my test to see what happens. My beefy macbook pro freezes up due to the infinite loop. This is as far as I got before the entire thing was unresponsive:https://github.com/cypress-io/cypress/assets/19196536/37ac01c1-bde7-4d59-9e9f-cb5976364d6c
It’s not a resources issue. Cypress is waiting for the redirect loop to stop.
It’s not clear why the redirect loop isn’t detected by Cypress and terminated. I thought we’d get that for free from the browser. I’m not sure how / if / when we can fix this.
In the meantime, the best solution would be to find out why the website has an infinite redirect loop and fix that - it’s definitely a bug in the website, although I agree Cypress really should provide a more actionable error (not sure how to detect this - it’s basically the hauling problem. I’m guessing when you visit in a regular browser session, it’ll bail after N redirects).
As for your situation right now – I’m not really sure what else to recommend. The best response I can come up with is “the website under test has a bug that is leading to an infinite redirect caused by X resource (TODO: find out which one). The test automation tool, Cypress, is unable to detect this, resulting in the test hanging due to getting stuck in an infinite redirect loop. I’d recommending inspecting X resource to find out why it’s cause the redirect”.
As for @dsolisp - https://www.saucedemo.com/ is working great for me. I’m not able to reproduce the experience you are having. Can you share some more information about your system?
See my comments in https://github.com/cypress-io/cypress/issues/27185#issuecomment-1625614195 about
saucedemo.Blocking all the trackers in a testing environment is a great idea @MikeMcC399 - I doubt any production website wants to count robots as real users, it messes up analytics.
the issue is very reproducible, as it says
there is no much code to add, just do a cy.visit() and for some reason when testing some pages it happens randomly.
my students are having lots of problems doing the visit command with https://www.saucedemo.com/ page
Im not sure why you guys are focusing on the whole test class, is just a simple cy.visit() failing with
When cy visit, url: CypressError: Timed out after waiting
60000msfor your remote page to load. Your page did not fire itsloadevent within60000ms. You can try increasing thepageLoadTimeoutvalue incypress.config.jsto wait longer. Browsers will not fire theloadevent until all stylesheets and scripts are done downloading. When thisloadevent occurs, Cypress will continue running commands.Hi @esbarila I too getting same error while I tried to run through CI. If you find any solution kindly respond to this issue.
Node v14.19.0
cypress v12.16.0
CypressError: Timed out after waiting
120000msfor your remote page to load.Your page did not fire its
loadevent within120000ms.You can try increasing the
pageLoadTimeoutvalue incypress.config.jsto wait longer.Browsers will not fire the
loadevent until all stylesheets and scripts are done downloading.When this
loadevent occurs, Cypress will continue running commands.