microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.89k stars 3.67k forks source link

[Feature] Extended "mediaEmulation" API #31767

Open Rajdeepc opened 3 months ago

Rajdeepc commented 3 months ago

🚀 Feature Request

For users looking to test code that might employ something like matchMedia('(hover: none) and (pointer: coarse)').matches, it would be awesome to be able to apply this context at testing time. We're currently able to test usage like matchMedia('(max-width: 800px)').matches via the page.setViewportSize(viewportSize) or matchMedia('print').matches via page.emulateMedia({media: 'print'), and I wonder if we could expand on emulateMedia, setViewportSize, and/or a new API to surface these extended realities.

It's possible that there is a combination of tangentially related settings that might similarly active this situation, in which case this may just be a documentation request, however the ability to make these changes during runtime, as is available with the other APIs I have listed would be very valuable for easy testing of these sorts of features.

Example

No response

Motivation

I'm sure that anyone who is working to test the responsively of their code across the growing number of contexts in which a web application can be delivered would benefit from being able to leverage such an addition.

Rajdeepc commented 3 months ago

Reopening from #11781

Rajdeepc commented 3 months ago

Hi @dgozman It would be great if you can share some updates if your team has or planning to prioritise this in coming months? This would be a great to have feature to enable device specific testing capabilities in our test pipeline.

dgozman commented 3 months ago

@Rajdeepc No plans for this one yet, sorry.