cy.visit() occasionally loads blank page
See original GitHub issueIs this a Feature or Bug?
A bug (either in Cypress, the browser or in our App)
Current behaviour:
Browser occasionally loads an empty/blank page and starts testing against it - but canβt find the expected elements.
This can happen to any spec. Often specs afterwards will run fine again.
- Cypress navigates to
/
but the website shows as a blank page in the recorded video/screenshots - Test gets an authentication token and reloads the website with the token configured
- Page still blank, cypress tests against the empty page and canβt find the expected elements, e.g.
CypressError: Timed out retrying: Expected to find element: 'input[name=password]', but never found it.
The code for the tests is roughly the following:
// test*.ts
beforeEach(() => {
cy.visit(`/`); // not logged in
// get auth token via API, set it on local storage and visit site again
cy.visit(`/`); // logged in
cy.get('#root'); // fails
});
// other.ts
it('general\\signin.ts', () => {
cy.visit(`/}`); // not logged in
cy.get('input[name=password]') // fails
.type(password);
}
Spec Tests Passing Failing Pending Skipped
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β test1.ts 00:13 2 2 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test2.ts 00:22 4 4 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test3.ts 00:11 2 2 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test4.ts 00:06 1 1 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test5.ts 00:06 1 1 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test6.ts 00:06 1 1 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Γ other.ts 01:52 108 100 8 - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Γ test7.ts 00:20 2 - 1 - 1 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test8.ts 00:05 1 1 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β test9.ts 00:05 1 1 - - - β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2 of 10 failed (20%) 03:31 123 113 9 - 1
Screenshot is from here but very similar to what I see.
Desired behavior:
Browser always loads and displays the the website when navigating to /
.
What Iβve tried
- Run with electron (headless and headed) and with chrome (all fail)
- Increase the timeout for
cy.get
to15
seconds (still fails) - Navigating to
/v=<number>
instead of/
to avoid any caching ( still fails) - Run with
npx cypress open
and thenRun all specs
(this works / has not failed yet) - Running similar tests against google.com and random react app from the web which passed so it seams this issue is not related to the testing environment but the combination of my website and Cypress CI.
Versions
Cypress | 3.3.1 |
OS | Windows 10 and Windows Server 2016 |
Browsers | Electron (headed/headless), Chrome |
Website | React based, makes use of websockets to load data |
Webserver | runs on the same machine as cypress |
To me it looks like the website is not quite compatible with Cypress CIβs testing behaviour - is there a list of pitfalls to know about when writing testable websites? Has anyone else had similar problems and found the problem or maybe a workaround?
Can I turn on some logging to get more insight into what may be going wrong? Configuring $env:DEBUG
didnβt produce helpful output for me, nor do the cypress/logs
. Maybe extracting the console.log
from the browser
The only post I found related to this (occasionally .visit() doesnβt load the page, only happening in CI) was here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:28
- Comments:43 (5 by maintainers)
Top GitHub Comments
Same here. This is very much still an issue on Cypress 3.8.2
I am also getting the same issue of blank page with cypress 9.5. I have upgraded to 9.5.2 version, still getting blank page after logging to my website.