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

Allow a way to configure device pixel ratio (DPR) for all headless browsers during cypress run #17597

Open
jennifer-shehane opened this issue Aug 4, 2021 · 4 comments
Labels
E2E Issue related to end-to-end testing topic: video 📹 type: feature New feature that does not currently exist

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Aug 4, 2021

What would you like?

Allow a way to configure device pixel ratio (DPR) of the machine for all browsers via a single config.

Why is this needed?

Other

  • How to we educate people that the DPR is only applying during cypress run?
  • Make it global config (can expand to suite/test level config if people ask for it).
  • What is the effect to setting DPR during cypress open mode? Is it weird? Let's not do that if it's weird.
  • What happens setting DPR via the command line flags versus CDP?

Example

These are current defaults for DPR (effectively) and would be exposed this way:

{
  "devicePixelRatio": {
    "runMode": 1,
    "openMode": null
  }
}
@jennifer-shehane jennifer-shehane added stage: proposal 💡 No work has been done of this issue type: feature New feature that does not currently exist and removed stage: to do labels Aug 4, 2021
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: proposal 💡 No work has been done of this issue stage: work in progress labels Aug 5, 2021
@jennifer-shehane jennifer-shehane changed the title Allow a way to configure device pixel ratio (DPR) for all browsers Allow a way to configure device pixel ratio (DPR) for all headless browsers during cypress run Aug 6, 2021
@kuceb
Copy link
Contributor

kuceb commented Aug 9, 2021

How about a global setting devicePixelRatio in cypress.json

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented Aug 24, 2021

Experiments from @bkucera on ways to set DPR:

chrome:

when using Emulation.setDeviceMetricsOverride to set dpr after browser launch

  • cy.screenshot resolution is doubled (you can see chrome scaling the app when we send the screenshot cdp command)
  • The video will remain 1280x720. therefore cdp dpr will not fix users wanting doubled video size or make them less blurry

when using --force-device-scale-factor=2

  • browser is launched at 2x size and both screenshots and video are double resolution
  • however the command log is wider since css pixel size has increased, so users will see proportionally less of their app without us changing css

firefox:

can use layout.css.devPixelsPerPx to set dpr dynamically or at launch

  • doubles screenshots and video
  • however the command log is wider since css pixel size has increased, so users will see proportionally less of their app without us changing css

@kuceb
Copy link
Contributor

kuceb commented Sep 7, 2021

Notes after looking at individual frames coming from cdp:
Chrome:
when using Emulation.setDeviceMetricsOverride to set dpr after browser launch:

  • screenshots change resolution, however individual video frames do not. The video frames from startScreencast only change resolution when Emulation.setDeviceMetricsOverride changes the actual screen size, not the dpr
  • the frames coming from startScreencast are compressed and have lossy artifacts, which match quality we see in uncompressed videos. Compression further reduces quality of the video recording

@b-sw
Copy link

b-sw commented Jul 25, 2023

@jennifer-shehane
Do you know if it's possible to set DPR on Electron browser as well?

@nagash77 nagash77 added the E2E Issue related to end-to-end testing label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing topic: video 📹 type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

4 participants