-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4c14646
activate main cypress tab before taking a screenshot
cacieprins dc0d6da
new tests to cover page activation behavior
cacieprins 4fa3d6f
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins 605223a
updates changelog
cacieprins 552dcb8
whitespace
cacieprins 444b3fc
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins 7bb8459
fix check-ts
cacieprins 2f8a433
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins 31915aa
reduce extension failure timeout to 500ms to account for origin bridg…
cacieprins 3dbfe85
only use tab activation workaround in chrome; default to Page.bringTo…
cacieprins 4c028d8
update unit tests
cacieprins 08ad591
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins eec4532
swap order of tests in 5016 system test
cacieprins a155d82
some debugging to try and hunt down firefox issue
cacieprins 27353a7
rm debug prev added - looks like sys test passed that time?
cacieprins 49a8434
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins 8d81379
rm debug emit from v2 extension
cacieprins 5f72d11
Merge branch 'develop' into cacie/fix/screenshot-timeout
cacieprins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,7 +337,6 @@ const automation = { | |
}) | ||
.then(fn) | ||
}, | ||
|
||
} | ||
|
||
module.exports = automation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
exports['e2e issue 5016 - screenshot times out after clicking target _blank / fails but does not timeout taking screenshot'] = ` | ||
|
||
==================================================================================================== | ||
|
||
(Run Starting) | ||
|
||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Cypress: 1.2.3 │ | ||
│ Browser: FooBrowser 88 │ | ||
│ Specs: 1 found (issue-5016.cy.js) │ | ||
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
|
||
|
||
──────────────────────────────────────────────────────────────────────────────────────────────────── | ||
|
||
Running: issue-5016.cy.js (1 of 1) | ||
|
||
|
||
issue 5016 | ||
✓ should take a normal screenshot | ||
1) should fail but not timeout while taking the screenshot | ||
✓ should not timeout taking screenshot when not failing | ||
|
||
|
||
2 passing | ||
1 failing | ||
|
||
1) issue 5016 | ||
should fail but not timeout while taking the screenshot: | ||
AssertionError: Timed out retrying after 4050ms: expected '<a>' to have attribute 'foo' | ||
[stack trace lines] | ||
|
||
|
||
|
||
|
||
(Results) | ||
|
||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ Tests: 3 │ | ||
│ Passing: 2 │ | ||
│ Failing: 1 │ | ||
│ Pending: 0 │ | ||
│ Skipped: 0 │ | ||
│ Screenshots: 3 │ | ||
│ Video: false │ | ||
│ Duration: X seconds │ | ||
│ Spec Ran: issue-5016.cy.js │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
|
||
|
||
(Screenshots) | ||
|
||
- /XXX/XXX/XXX/cypress/screenshots/issue-5016.cy.js/issue 5016 -- should take a no (YxX) | ||
rmal screenshot.png | ||
- /XXX/XXX/XXX/cypress/screenshots/issue-5016.cy.js/issue 5016 -- should fail but (YxX) | ||
not timeout while taking the screenshot (failed).png | ||
- /XXX/XXX/XXX/cypress/screenshots/issue-5016.cy.js/issue 5016 -- should not timeo (YxX) | ||
ut taking screenshot when not failing.png | ||
|
||
|
||
==================================================================================================== | ||
|
||
(Run Finished) | ||
|
||
|
||
Spec Tests Passing Failing Pending Skipped | ||
┌────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ ✖ issue-5016.cy.js XX:XX 3 2 1 - - │ | ||
└────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
✖ 1 of 1 failed (100%) XX:XX 3 2 1 - - | ||
|
||
|
||
` |
6 changes: 6 additions & 0 deletions
6
system-tests/projects/config-screenshot-on-failure-enabled/cypress.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
screenshotOnRunFailure: true, | ||
e2e: { | ||
supportFile: false, | ||
}, | ||
} |
18 changes: 18 additions & 0 deletions
18
system-tests/projects/config-screenshot-on-failure-enabled/cypress/e2e/issue-5016.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// https://github.com/cypress-io/cypress/issues/5016 | ||
describe('issue 5016', { | ||
screenshotOnRunFailure: true, | ||
}, function () { | ||
it('should take a normal screenshot', function () { | ||
cy.visit('/cypress/fixtures/issue-5016/index.html').screenshot() | ||
}) | ||
|
||
it('should fail but not timeout while taking the screenshot', function () { | ||
cy.visit('/cypress/fixtures/issue-5016/index.html') | ||
cy.get('a').click().should('have.attr', 'foo') | ||
}) | ||
|
||
it('should not timeout taking screenshot when not failing', function () { | ||
cy.visit('/cypress/fixtures/issue-5016/index.html') | ||
cy.get('a').click().screenshot() | ||
}) | ||
}) |
5 changes: 5 additions & 0 deletions
5
...ests/projects/config-screenshot-on-failure-enabled/cypress/fixtures/issue-5016/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!doctype html> | ||
|
||
<body> | ||
<a target="_blank" href="./new.html">New Tab</a> | ||
</body> |
3 changes: 3 additions & 0 deletions
3
...-tests/projects/config-screenshot-on-failure-enabled/cypress/fixtures/issue-5016/new.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!doctype html> | ||
|
||
<html></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const systemTests = require('../lib/system-tests').default | ||
|
||
describe('e2e issue 5016 - screenshot times out after clicking target _blank', function () { | ||
systemTests.setup() | ||
|
||
systemTests.it('fails but does not timeout taking screenshot', { | ||
project: 'config-screenshot-on-failure-enabled', | ||
sanitizeScreenshotDimensions: true, | ||
snapshot: true, | ||
expectedExitCode: 1, | ||
browser: '!webkit', | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andelectron
both seem to work as expected prior to the fix.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