Testcafe: Screenshots does not work in docker if resized window

Created on 26 Oct 2017  路  10Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Reporting a bug

What is the current behavior?

Screenshots fail when trying to take screenshot after a test has resized the window. This only applies to the docker image.

The error thrown is

 Warnings (1):
 --
  Was unable to take a screenshot due to an error.

  Command failed:
  /opt/testcafe/node_modules/testcafe-browser-tools/bin/linux/musl-64/screenshot
  800001
  /tests/screenshot/2017-10-26_01-43-12/test-1/Chrome_59.0.3071_Linux_0.0.0/1.png
  X Error of failed request:  BadMatch (invalid parameter attributes)
    Major opcode of failed request:  73 (X_GetImage)
    Serial number of failed request:  13
    Current serial number in output stream:  13

What is the expected behavior?

A screenshot should be generated

How would you reproduce the current behavior (if this is a bug)?

Run the code below

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://www.google.com

Test code

fixture `Reproduce bug`
    .page `https://www.google.com`;

test('Will fail', async t => {
    await t.resizeWindow(1280,800)
    await t.takeScreenshot()
});

Specify your

  • operating system: Mac OS X 10.11.5
  • testcafe version: v0.18.1
  • node.js version: v6.10.3
docker server Linux Auto-locked browser natives bug

Most helpful comment

Encountering similar problem while running in Docker within Gitlab CI and already set Xvfb to higher resolution. Still the same errors.

All 10 comments

Hello @FredrikSeidl!

I've reproduced the bug, need some time to investigate it, thank you for the feedback, I'm trying to find a workaround now.

I have found that it happens when Chrome window resized to be bigger that virtual screen size. I can't figure out why but looks like that Chrome doesn't works well with Xvfb in this case. The problem can't be reproduced on a real X11 server.

As a workaround, you can set bigger virtual screen size by passing environment variables SCREEN_WIDTH and SCREEN_HEIGHT to container, e.g.:

docker run -it -e "SCREEN_WIDTH=3840" -e "SCREEN_HEIGHT=2160" -v ~/tests:/tests testcafe/testcafe -s /tests/screenshots 'chromium --no-sandbox' /tests

I think we need to increase default screen size to 1920x1080 and emit descriptive warning or error on resizing if the specified size is bigger than the screen size.

Encountering similar problem while running in Docker within Gitlab CI and already set Xvfb to higher resolution. Still the same errors.

I get the same error even without resizingWindow.
Found that if I use maximizeWindow the screenshot will work.

Like already mentioned in #1913 , switching to headless mode also resolved this issue. Not sure if it's really related to this, but now it works.

Also getting same error
_Error of failed request: BadMatch (invalid parameter attributes)_

For failed tests for page with widgets.

Hi @shaikatz @neilmatillano, could you try to increase Xvfb screen size, and use headless mode?

docker run -it -e "SCREEN_WIDTH=3840" -e "SCREEN_HEIGHT=2160" -v ~/tests:/tests testcafe/testcafe -s /tests/screenshots 'chromium:headless --no-sandbox' /tests

Hi, I get the same error message as mentioned in the first post.
Increasing the screen size, and using headless mode doesn't help.

This issue must be fixed by https://github.com/DevExpress/testcafe/pull/2492. I'll notify you when a build with the fix will be published on NPM. Feel free to try the fixed build and reopen the issue if the problem isn't solved in your environment.

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inikulin picture inikulin  路  3Comments

calisven picture calisven  路  3Comments

Turkirafaa picture Turkirafaa  路  3Comments

darkowic picture darkowic  路  3Comments

AndreyBelym picture AndreyBelym  路  3Comments