-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
beforeunload when running Electron #796
Comments
I'm confused why this behavior causes tests in Electron to fail. What about your test code requires this dialog? Can you post your test code? Electron isn't showing the dialog because its using Chromium 53, and you're likely using a new version of Chrome which has had this feature implemented. You could also avoid adding this event listener entirely under Cypress tests. if (window.Cypress) {
...
} |
I've updated the comment, it's happening whenever you change something within DOM. |
Okay thank you - this should be enough for us to reproduce. |
Also BTW you could run Chrome in CI by using the |
Good to know. Regarding window.Cypress, I'd rather leave the code agnostic to testing frameworks, and I can live with a global signature of the listener, that I can control in the testing environment. |
That's fair. At the very least you could conditionally make the event listener global only in the Cypress test environment. There is potentially a different approach here where you use the unload event listeners from within Cypress itself and then you remove the In that situation you could test that the returnValue was set correctly (programmatically) but remove it to prevent the browser from reacting to it - since you don't care about it anyway. |
It appears this feature was implemented in I think the actual fix for this are Lifecycle Events where instead of navigating the |
I thought this may have been fixed in 3.3.0 Cypress version, but it's not. Experiencing this same issue documented in |
I have exactly the same issue with 3.3.0 with Electron only. Chrome works fine even the error message stays in the console |
Related: #2118 |
Closing as duplicate of #2118 There are workarounds as well as a full explanation of this issue in this comment: #2118 (comment) |
Current behavior:
When I run a test suite on a page that has a
beforeunload
event listener - hence, it triggers an alert -, first test goes fine, but the second test onwards fails to open the page.This works fine using Chrome, as the Debugger console shows the following:
This makes CI headless tests unfeasible, as they fail for no consistent reason.
Desired behavior:
Electron built-in headless browser should prohibit beforeunload behaviour - same as Chrome does.
How to reproduce:
Open a page that has
in two tests within the same test suite.
Test code:
Additional Info (images, stack traces, etc)
I managed to fix this by exposing the listener in window, and run
straight after
The text was updated successfully, but these errors were encountered: