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

Screenshots does not work in docker if resized window #1918

Closed
FredrikSeidl opened this issue Oct 26, 2017 · 10 comments
Closed

Screenshots does not work in docker if resized window #1918

FredrikSeidl opened this issue Oct 26, 2017 · 10 comments
Labels
AREA: docker AREA: server OS: Linux STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@FredrikSeidl
Copy link

FredrikSeidl commented Oct 26, 2017

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
@AndreyBelym
Copy link
Contributor

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.

@AndreyBelym AndreyBelym added AREA: server OS: Linux SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug). labels Oct 26, 2017
@AlexanderMoskovkin AlexanderMoskovkin added this to the Sprint #10 milestone Oct 30, 2017
@AndreyBelym
Copy link
Contributor

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.

@morph027
Copy link

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

@shaikatz
Copy link

shaikatz commented Feb 4, 2018

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

@morph027
Copy link

morph027 commented Feb 4, 2018

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.

@neilmatillano
Copy link

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

For failed tests for page with widgets.

@AndreyBelym
Copy link
Contributor

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

@hauptrolle
Copy link

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

@AndreyBelym AndreyBelym modified the milestones: Planned, Sprint #12 May 15, 2018
@AndreyBelym
Copy link
Contributor

This issue must be fixed by #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.

@lock
Copy link

lock bot commented Mar 28, 2019

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.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: docker AREA: server OS: Linux STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

7 participants