cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.74k stars 3.16k forks source link

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

Open jennifer-shehane opened 3 years ago

jennifer-shehane commented 3 years ago

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

Example

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

{
  "devicePixelRatio": {
    "runMode": 1,
    "openMode": null
  }
}
kuceb commented 3 years ago

How about a global setting devicePixelRatio in cypress.json

jennifer-shehane commented 3 years ago

Experiments from @Bkucera on ways to set DPR:

chrome:

when using Emulation.setDeviceMetricsOverride to set dpr after browser launch

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

firefox:

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

kuceb commented 3 years ago

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

b-sw commented 1 year ago

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