A bug (either in Cypress, the browser or in our App)
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.
/
but the website shows as a blank page in the recorded video/screenshotsCypressError: 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.
Browser always loads and displays the the website when navigating to /
.
cy.get
to 15
seconds (still fails)/v=<number>
instead of /
to avoid any caching ( still fails)npx cypress open
and then Run all specs
(this works / has not failed yet)|||
|-|-|
|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.
@nitzel If you set $env:DEBUG to cypress:*
, it will capture all the logs from Cypress which will be helpful to debug the problem: https://docs.cypress.io/guides/guides/debugging.html#Print-DEBUG-logs
Share them here and hopefully we can figure it out.
Thank you, here they are: https://gist.github.com/nitzel/ae7928c9558df6a209d7a511cc046ae2
I've stripped away our website's console.log messages and all tests except for the 8th and 9th (the 9th one failed) to shorten the massive log.
We seem to be having a similar issue. A few weeks ago we had a feature branch unexpectedly start failing some tests. All the test failures were happening immediately after cy.visit('/a_specific_url')
of one specific url. The failures seem to have the same behavior that nitzel describes above. Screenshot attached. Basically the test thinks it successfully visited a url but the page itself is blank and the url appears as just localhost. A few bizarre things:
cy.visit('/a_different_url')
.Update: reverting to cypress 3.1.5 does stop the failures though reverting versions is not a solution and just a temporary fix.
Addition (7/26): Just stumbled upon https://github.com/cypress-io/cypress/issues/3201 and the screenshot obtained there in circleci matches what I was seeing in my circleci tests.
We have similar issue. As @aviaweinstein mentioned we changed it back to Cypress 3.1.5 fixed it.
Our website is react based. There are two xhrs sent after long time with Cypress 3.4.0 (over 2 minutes)
I change the 'pageLoadTimeout' in cypress.json to 3 minutes seems fix the issue.
The xhrs below are sent after around 2 mins.
But with Cypress 3.1.5 even 'pageLoadTimeout' is 10 seconds would load the two xhr instantly.
I cannot tell the differences from the console output. If you need more information I am happy to provide.
Just ran into this, I believe Cypress is not letting page sending out ajax/xhr/api requests when visit() is happening. This also only happens on Circie CI headless. Not locally
Thanks everyone for the detailed information!
If this behavior can be narrowed down to only happening beginning in 3.2.0 then it definitely sounds like a bug.
@sikanhe @nitzel Does downgrading to Cypress 3.1.5 fix the issue for you?
Looking at the changelog for 3.2.0 it isn't immediately apparent what code could have affected this, although there is a long list of dep updates, so I'll start looking through those.
This is going to be a lot harder for us to even test a fix against though without a reproducible example to run against, so anyone that can provide that would be appreciated.
This looks very similar to the issues I am experiencing on Travis CI (Ubuntu 16.0.4) with Electron 61.
I have tried running the tests in both headless and headed mode on Travis. The failures are sporadic. The tests pass every time on my laptop (OS X v10.14.6). When I run the tests on my laptop I typically use the GUI and set the browser to Chrome. However, I've also tried Electron in the GUI as well as headless Electron via the terminal. Everything passes on my laptop
I've attached some sample screenshots from recordings:
Unfortunately we will have to close this issue if there is not enough information to reproduce the problem. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.
Please everyone try the most current version of Cypress and comment in this issue with a reproducible example ๐
Hello so I have recently run into this issue as well. It runs perfectly fine in the GUI but when I run it headless, it consistently fails every time due to a blank white page.
I am running:
Below is a gif of the headless run and the code:
describe('Visit URL', () => {
it('Visit page', () => {
cy.visit('https://dev-us.insightbot.io/smoke-test-landing-184926')
cy.getByText('Chat On The Web')
})
})
Same here. This is very much still an issue on Cypress 3.8.2
@nicholassiu the url is not loading https://dev-us.insightbot.io/smoke-test-landing-184926
Yes, I have the same problem, after few times, I get just blank page
My Test did not have this issue when running in circleCi until I updated from cypress 3.8.2 -> 3.8.3. When I rerun the test all is well. Unfortunately I am not able to reproduce this issue as it happens sporadically.
App being tested is built in vue.
I have the same problem, for many days now... What is weird is that this behaviour is not systematic (even though really frequent).
@jennifer-shehane : as you're on the subject (I saw you answers in this ticket and in all those related to blank pages ), I noticed some points that could maybe clarify or give some clues to understand :
1- it seems that only my tests where I log in through the API are concerned
My tests where I don't have to log in are always ok.
To log in, I use a stub that connects directly through our api, without having to log through the interface.
I thus wrote the same test but where the logging is done through our connection interface : this test is always successfull (no blank page).
2- the bug came suddenly
All my tests (including the ones connecting through the api) were always launched successfully before the 28 january 2020, whatever the number of times I launched them (successively or not).
Could the bug come from cypress?
I had the version 3.6.0 of cypress installed, and everything was ok. I didn't understand why it could have changed so suddenly, but decided anyways to install the latest version (3.8.3), just in case. But the bug was (is) still there.
Could the bug come from our app under test?
We have spend a lot of time looking for changes we could have done that could explain this regression, but nothing came out.
Furthermore, sometimes the tests still pass, without blank screen.
Thus, I ask me now : Could the bug come from Chromium???
Yet, today, in cypress documentation on "launching browsers", I read that "the Chrome browser is evergreen - meaning it will automatically update itself, sometimes causing a breaking change in your automated tests." ( https://on.cypress.io/launching-browsers#Browsers )
Given that Chromium seems to be the unique element that updates automatically, could it be possible that this blank page error comes from it ?
3- I found a way to get around this bug, but it's not sustainable (still randomly successful)
When I launch a successfull test (with no need of login) before a test that cames into error (where there is an api login step), it many times is successfull.
It is better than a total and systematic blank page, but it doesn't work each time, which still is a lot frustrating...
If anybody has an idea of why this bug has appeared and above all how to fix it, please let me know : I am stuck and my automation POC is threatened :s
Thanks !
@jennifer-shehane : A colleague of mine has found a solution to this blank page issue.
Actually, I have defined a baseUrl
in my cypress.json
file.
My tests thus contained a relative path in their cy.visit()
. For example, I have tests with cy.visit('/search')
.
We really don't know why, but now, to be successful, the test must have a dot before the slash.
In my former example, by typing cy.visit('./search')
everything is ok now.
I don't know if this is a solution for everybody, but I hope it could help at least those who use a baseUrl
, like us.
We've been seeing this issue for a while now. It happens intermittently when running tests on CircleCI and we found it was only reproduceable locally when running tests headlessly (passed everytime in the UI).
I found a brief workaround in adding a short wait cy.wait(100)
that seemed to work for a while, but after upgrading from 3.8.1 to 3.8.3 this came back. I increased the wait slightly and this prevents these tests from timing out everytime, but they do still keep happening intermittently.
@Rose-Lutz I tried your fix (we do use a baseUrl
) but that didn't solve it.
Happens for my team locally as well... blacklisting GA and google fonts didn't help.
Any ideas how we could approach debugging this?
I can't create an issue, because there's no reliable way to reproduce it, only shows up every ~100 tests.
Can anyone find solution of this issue?
i am getting blank page while using cy.visit(). My Cypress version is 4.0.2
@nicholassiu I cannot get the url you provided to load in a normal browser outside of Cypress. It results in a blank page with many errors in the DevTools Console. This is not related to Cypress
Yet again, I am back to stating that we will have to close this issue as there is not enough information to reproduce the problem. This does not mean that the issue is not happening - it just means that we do not have a path to move forward.
We really, really want to help fix this issue - but we can't without a single way given to reproduce it.
@jennifer-shehane I get it, but what can we provide to help?
I obviously can't give you access to my app code, because of compliance issues and other things, and on the other hand our 100++ tests would be useless in that case?
I'd be happy to provide logs, debug extract and whatever we may provide. I just have no idea what may be helpful in this case.
I'd love at least have an option to retry the cy.visit() after ~15 seconds if it failed. But I don't have an option to handle this error with cypress either.
I'd love at least have an option to retry the cy.visit() after ~15 seconds if it failed. But I don't have an option to handle this error with cypress either.
@Jacek-fstack have you tried this plugin?
https://github.com/Bkucera/cypress-plugin-retries
this one may also be worth investigating
https://github.com/NoriSte/cypress-wait-until
we had similar issues a long while ago, and iirc we used some combination of those to get around it
@danitt I looked at that, but it doesn't seem like I can isolate retries just for one command [the cy.visit().
Or am I mistaken and it is possible?
@danitt I looked at that, but it doesn't seem like I can isolate retries just for one command [the cy.visit().
Or am I mistaken and it is possible?
@Jacek-fstack no idea, if it were me I'd just apply it globally so you can at least move forward; probably have some other flakes that would benefit from retries anyway ยฏ_(ใ)_/ยฏ
Understood, thank you for the reply :)
Update for anyone interestd, I managed to 'get around' the issue, by forking the cypres-retries plugin and changing the code a bit, line 123 in the support.js file in that plugin to
if(err.toString().includes("Your page did not fire its 'load' event within")) {
HOWEVER the bug is still a pain, it retries sometimes 2 times and event fails after 3 test retries, because the cy.visit was not triggered.
@jennifer-shehane
Is there a chance that cypress could expose the cy.visit() command, as a jQuery WITHOUT the assertion, so I could make my own assertion and not having to repeat the whole tests in case the page does not load?
For the future:
It seems like the new update fixed that issue for us... AND tests are WAY faster than before.
Good job, cypress team.
I've been seeing the same issue with sporadic blank pages with Cypress 4.3.0, switching to Chrome instead of Electron seems to have fixed it! ๐ค
cypress run --browser chrome --headless
I'm also experiencing this issue with version 4.5.0 and get a white page after logging into my application.
Same issue with version 3.8.3 and upgraded to 4.5.0 white page after running 2-3 steps
Why cypress has so many bugs?
Same issue with version 3.8.3 and upgraded to 4.5.0 white page after running 2-3 steps
Why cypress has so many bugs?
Any update on this ?
I am not sure if this is related, but when I try to do visual regression, I get a blank screen unless I perform some other action:
cy.visit('/');
cy.matchImageSnapshot('home');
The above creates a blank snapshot (just a white PNG file).
cy.visit('/');
cy.get('h1').contains('Home');
cy.matchImageSnapshot('home');
The above produces a correct snapshot of the page.
UPDATE: Cypress starts working again, suddenly.
Maybe it's related to GCP or other outside environments? idk.
Anyway, ignore following my initial problem, thanks.
Cypress version: 5.5.0
I have come across a similar issue.
Cypress suddenly stopped working this afternoon.
Devtools console says it can't find bundle.js.
GET https://myappsite.com/assets/b447b79ff50f19679aaa-bundle.js net::ERR_ABORTED 404 (Not Found)
/#/login:1 Refused to apply style from 'https://myappsite.com/assets/b447b79ff50f19679aaa-main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
I found that this bundle.js
doesn't exist on the server anymore, though I use Chrome it can show the page properly using a new bundle.js
.
Does anyone know any workarounds?
I have spent whole afternoon to solve this and no dice.
I'm at my wit's end.
Most helpful comment
Same here. This is very much still an issue on Cypress 3.8.2