testcafe
testcafe copied to clipboard
Unable to take screenshots in headless mode
What is your Scenario?
Take screenshots on failed tests with quarantine mode in chrome:headless or edge headless.
What is the Current behavior?
When running on chrome:headless, screenshots do not work
What is the Expected behavior?
On test fails it will re-try until attempt limit and take screenshots at each run.
What is your public website URL? (or attach your complete example)
www.google.com
What is your TestCafe test code?
test.js:
fixture.only(`Test`).page(`www.google.com`)
test.only(`Test screenshot headless`, async t => {
await t.wait(2)
await t.expect(false).ok(`This is a test`)})
test.only(`Test screenshot headless`, async t => {
await t.wait(2)
await t.expect(false).ok(`This is a test`)})
test.only(`Test screenshot headless`, async t => {
await t.wait(2)
await t.expect(false).ok(`This is a test`)})
test.only(`Test screenshot headless`, async t => {
await t.wait(2)
await t.expect(false).ok(`This is a test`)})
Your complete configuration file
{
"browsers": "chrome",
"src": [
"./tests/login.test.js"
],
"screenshots": {
"takeOnFails": true,
"path": "./screenshots/"
},
"reporter": [
{
"name": "list"
}
],
"quarantineMode": {
"successThreshold": 1,
"attemptLimit":3
},
"skipJsErrors": true,
"pageLoadTimeout": 3000
}
Your complete test report
testcafe -c 3 edge:headless ./tests/login.test.js
Using locally installed version of TestCafe.
The "src" and "browsers" options from the configuration file will be ignored.
Running tests in:
- Microsoft Edge 103.0.1264.77 / Windows 11
- Microsoft Edge 103.0.1264.77 / Windows 11
- Microsoft Edge 103.0.1264.77 / Windows 11
× Test - Test screenshot headless
1) AssertionError: This is a test: expected false to be truthy
Browser: Microsoft Edge 103.0.1264.77 / Windows 10
133 |
134 |fixture.only(`Test`).page(`www.google.com`)
135 |
136 |test.only(`Test screenshot headless`, async t => {
137 | await t.wait(2)
> 138 | await t.expect(false).ok(`This is a test`)})
139 |
140 |test.only(`Test screenshot headless`, async t => {
141 | await t.wait(2)
142 | await t.expect(false).ok(`This is a test`)})
143 |
at <anonymous> (C:\tests\login.test.js:138:24)
at asyncGeneratorStep (C:\tests\login.test.js:4:291)
at _next (C:\tests\login.test.js:4:629)
× Test - Test screenshot headless
1) AssertionError: This is a test: expected false to be truthy
Browser: Microsoft Edge 103.0.1264.77 / Windows 10
137 | await t.wait(2)
138 | await t.expect(false).ok(`This is a test`)})
139 |
140 |test.only(`Test screenshot headless`, async t => {
141 | await t.wait(2)
> 142 | await t.expect(false).ok(`This is a test`)})
143 |
144 |test.only(`Test screenshot headless`, async t => {
145 | await t.wait(2)
146 | await t.expect(false).ok(`This is a test`)})
147 |
at <anonymous> (C:\tests\login.test.js:142:24)
at asyncGeneratorStep (C:\tests\login.test.js:4:291)
at _next (C:\tests\login.test.js:4:629)
× Test - Test screenshot headless
1) AssertionError: This is a test: expected false to be truthy
Browser: Microsoft Edge 103.0.1264.77 / Windows 10
141 | await t.wait(2)
142 | await t.expect(false).ok(`This is a test`)})
143 |
144 |test.only(`Test screenshot headless`, async t => {
145 | await t.wait(2)
> 146 | await t.expect(false).ok(`This is a test`)})
147 |
148 |test.only(`Test screenshot headless`, async t => {
149 | await t.wait(2)
150 | await t.expect(false).ok(`This is a test`)})
at <anonymous> (C:\tests\login.test.js:146:24)
at asyncGeneratorStep (C:\tests\login.test.js:4:291)
at _next (C:\tests\login.test.js:4:629)
× Test - Test screenshot headless
1) AssertionError: This is a test: expected false to be truthy
Browser: Microsoft Edge 103.0.1264.77 / Windows 10
145 | await t.wait(2)
146 | await t.expect(false).ok(`This is a test`)})
147 |
148 |test.only(`Test screenshot headless`, async t => {
149 | await t.wait(2)
> 150 | await t.expect(false).ok(`This is a test`)})
at <anonymous> (C:\tests\login.test.js:150:24)
at asyncGeneratorStep (C:\tests\login.test.js:4:291)
at _next (C:\tests\login.test.js:4:629)
4/4 failed (18s)
Warnings (2):
--
The "src" and "browsers" options from the configuration file will be ignored.
--
Was unable to take a screenshot due to an error.
Error: Unexpected end of input
at module.exports.ChunkStream._end (C:\node_modules\pngjs\lib\chunkstream.js:100:7)
at module.exports.ChunkStream._process (C:\node_modules\pngjs\lib\chunkstream.js:203:12)
at module.exports.ChunkStream.end (C:\node_modules\pngjs\lib\chunkstream.js:90:10)
at exports.PNG.PNG.end (C:\node_modules\pngjs\lib\png.js:98:16)
at exports.PNG.PNG.parse (C:\node_modules\pngjs\lib\png.js:88:8)
at Object.readPng (C:\node_modules\testcafe\src\utils\promisified-functions.js:25:9)
at BrowserProviderPluginHost.takeScreenshot (C:\node_modules\testcafe\src\browser\provider\built-in\dedicated\base.js:90:30)
at BrowserProvider.takeScreenshot (C:\node_modules\testcafe\src\browser\provider\index.ts:409:13)
at Capturer._takeScreenshot (C:\node_modules\testcafe\src\screenshots\capturer.js:123:9)
at C:\node_modules\testcafe\src\screenshots\capturer.js:152:13
Screenshots
No response
Steps to Reproduce
- Write a fixture with google as page
- In configuration file add screenshot and quarantine mode options
- run the test in
:headless
- observe that there is an error at the end
- observe that quarantine mode did not work
TestCafe version
both local and global are 1.20.1
Node.js version
v18.4.0
Command-line arguments
testcafe chrome:headless ./tests/login.test.js
Browser name(s) and version(s)
Microsoft Edge 103.0.1264.77, Chrome 104.0.5112.81
Platform(s) and version(s)
Windows 11
Other
On another laptop with windows 10 @ 1.18.1 TestCafe it works fine. Before updating to 1.20.1, I faced the same issue on 1.18.1 on this windows 11 laptop.
This issue has been faced before but was supposed to be fixed (Link to #6886 comment )
I managed to reproduce the issue with NodeJS v18.7.0 and Windows 10. Thank you for reporting this. We'll research this issue. Until it is fixed, please use the stable NodeJS version.
Release v2.1.0-rc.1 addresses this.