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

cy.screenshot bug fixes and enhancements #1793

Merged
merged 3 commits into from
May 29, 2018
Merged

cy.screenshot bug fixes and enhancements #1793

merged 3 commits into from
May 29, 2018

Conversation

brian-mann
Copy link
Member

fixes #1792

…een rendering incorrectly upscaling screenshots

- when electron is running in offscreen headless mode with a retina
screen it incorrectly sets devicePixelRatio to one, but still takes a
screenshot at 2x ratio, which then upscales the pixels and blurs the
pixels, which defeats the pixel checking.
- this fix forces electron to render only at a device pixel ratio of 1
when headless. it works normally when headed without having to do
anything special
- this fixes a bug where pixel coordinate checking was hard coded and
was not factoring in device ratio
@brian-mann brian-mann changed the title wait only 1500ms to take screenshots cy.screenshot bug fixes and enhancements May 29, 2018
@brian-mann brian-mann merged commit 69c2217 into develop May 29, 2018
@jennifer-shehane jennifer-shehane deleted the issue-1792 branch July 24, 2018 16:57
# to force retina screens to not
# upsample their images when offscreen
# rendering
require("./util/electron_app").scale()
Copy link
Contributor

@sebinsua sebinsua Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brian-mann Hey, I had an issue in which I couldn't use the image regression plugin cypress-image-snapshot because the snapshots created were different between headed mode and headless mode.

I worked out that this was because BrowserWindow#capturePage resolves to an image of a different size dependent on the scale factor, and by default cypress open was giving me a scale factor which was different from the one set in headless mode.

How would you feel about there being a configuration option to set a scale factor across all browsers? Currently, this hardcodes it as 1, and there isn't a way of setting it for a headed electron environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize some screenshot taking code, remove max retries, just wait for 1500ms
2 participants