You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for emulating devices for hover and pointer css media queries #282
The pointer, any-pointer, hover and any-hover media queries allow you to style a page based on the available input devices. Currently there is no way I can see to change how cuprite/ferrum responds to these queries.
E.g. I have a site where the navigation is different based on whether you have a mouse or not. Currently, only the touch version of the site can be tested because @media (any-hover: hover) will never work in a cuprite-driven browser.
This isn't a Cuprite issue: it's how Chrome reports input devices. When there's no mouse, as in headless Chrome on Linux or in Docker, Chrome matches (hover: none) and (pointer: none). CDP can't override these, since Emulation.setEmulatedMedia ignores hover and pointer, so the fix is to start Chrome with flags that declare a mouse:
primaryPointerType=4 alone isn't enough, because it only fixes pointer. The hover values are needed for hover and any-hover. With all four set, Chrome 155 on Linux matches (hover: hover), (any-hover: hover), (pointer: fine) and (any-pointer: fine).
If you connect to a remote browser with url:, browser_options doesn't apply. In that case, pass the same --blink-settings=... flag to the Chrome started in the container.
For the touch version, the new emulate: option from #338 (e.g. emulate: :iphone_14) or mobile: true switches Chrome to (hover: none) and (pointer: coarse).
Activity
phylor commentedon Dec 4, 2024
If you can live with always having the same setting, you can set the browser option
blink-settingsfor this.For example:
route commentedon Oct 15, 2026
This isn't a Cuprite issue: it's how Chrome reports input devices. When there's no mouse, as in headless Chrome on Linux or in Docker, Chrome matches
(hover: none)and(pointer: none). CDP can't override these, sinceEmulation.setEmulatedMediaignoreshoverandpointer, so the fix is to start Chrome with flags that declare a mouse:primaryPointerType=4alone isn't enough, because it only fixespointer. The hover values are needed forhoverandany-hover. With all four set, Chrome 155 on Linux matches(hover: hover),(any-hover: hover),(pointer: fine)and(any-pointer: fine).If you connect to a remote browser with
url:,browser_optionsdoesn't apply. In that case, pass the same--blink-settings=...flag to the Chrome started in the container.For the touch version, the new
emulate:option from #338 (e.g.emulate: :iphone_14) ormobile: trueswitches Chrome to(hover: none)and(pointer: coarse).fix(page): leave touch emulation alone on resize unless mobile is set (…