-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: screenshot() times out when the main Cypress tab is not focused #29038
Conversation
Passing run #54404 ↗︎
Details:
Review all test suite changes for PR #29038 ↗︎ |
…Front in headless mode
sanitizeScreenshotDimensions: true, | ||
snapshot: true, | ||
expectedExitCode: 1, | ||
browser: '!webkit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only run into the issue in chrome
. firefox
and electron
both seem to work as expected prior to the fix.
browser: '!webkit', | |
browser: 'chrome', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also be good to just exercise the behavior since it is a change to CDP automation itself and make sure the behavior doesn't regress in those browsers for whatever reason
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
cypress run
#5016Additional details
When the Renderer for a given Chromium tab is paused, CDP commands that query that renderer hang until the renderer is unpaused. Unfortunately, this causes issues with
cy.screenshot()
in both run and open mode, if the main Cypress tab becomes unfocused. This happens when an anchor is clicked within a test that has atarget
of_blank
, among other scenarios. To keep tests running, we timeout on capturing a screenshot after 30 seconds.When in
run
mode, this causes issues when a test assertion fails after a new tab has been opened. By default, Cypress takes a screenshot when an assertion fails. If this screenshot times out, the original assertion failure is replaced by the screenshot timeout error.To fix this, we now attempt to activate the main Cypress tab in Chromium browsers before taking a screenshot. First, we request the extension to activate the main tab. This can fail if the Cypress extension has been disabled. As a last resort, the
Page.bringToFront
command is issued to CDP. This is less desirable, as it causes the browser to steal focus.Steps to test
See:
./system-tests/projects/config-screenshot-on-failure-enabled
. To test with the extension disabled, modify./system-tests/test/issue_5016_spec.js
and pass bothnoExit: true
andheaded: true
. Once the test completes, disable the extension inchrome://extensions/
and reload the main Cypress tab.How has the user experience changed?
PR Tasks
cypress-documentation
? Adds section to cy.screenshot() about Chromium tab activation behavior cypress-documentation#5735type definitions
?