Skip to content
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

Unable to take screenshots in headless mode #7224

Closed
port-eighty opened this issue Aug 9, 2022 · 3 comments · Fixed by #7054
Closed

Unable to take screenshots in headless mode #7224

port-eighty opened this issue Aug 9, 2022 · 3 comments · Fixed by #7054
Labels
FREQUENCY: level 1 TYPE: bug The described behavior is considered as wrong (bug).

Comments

@port-eighty
Copy link

port-eighty commented Aug 9, 2022

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

  1. Write a fixture with google as page
  2. In configuration file add screenshot and quarantine mode options
  3. run the test in :headless
  4. observe that there is an error at the end
  5. 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.

@port-eighty port-eighty added the TYPE: bug The described behavior is considered as wrong (bug). label Aug 9, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 9, 2022
@port-eighty
Copy link
Author

This issue has been faced before but was supposed to be fixed (Link to #6886 comment )

@AlexKamaev
Copy link
Contributor

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.

@github-actions
Copy link

github-actions bot commented Nov 3, 2022

Release v2.1.0-rc.1 addresses this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
2 participants