question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page.emulateMediaFeatures([{ name: 'hover', value: 'hover' }]) throws error

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 2.0.0, Headless
  • Platform / OS version: Ubuntu 18.04.3 LTS
  • URLs (if applicable):
  • Node.js version: v10.16.3

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Create a new page:
    const page = await browser.newPage()
    
  2. Emulate the hover media query:
    await page.emulateMediaFeatures([{ name: 'hover', value: 'hover' }])
    

What is the expected result?

The feature should be emulated.

What happens instead?

The exception Unsupported media feature: hover is thrown

Context

When running Puppeteer headlessly on Linux, the result of the following media query is false:

window.matchMedia('(hover: hover)').matches

Meanwhile on a Mac, the same query returns true.

I would like to test media queries in our e2e tests, and not being able to control this behavior prevents this from being possible.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

1reaction
ReDrUmcommented, Sep 15, 2020

Me too 👍 Support for pointer would be nice too e.g. @media (hover: hover) and (pointer: fine)

0reactions
OrKoNcommented, Sep 6, 2022

If some of the values are actually supported by CDP, we can open them up in Puppeteer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

page.emulateMediaFeatures([{ name: 'hover', value ... - GitHub
emulateMediaFeatures([{ name: 'hover', value: 'hover' }]) throws error #5096 ... The exception Unsupported media feature: hover is thrown.
Read more >
page.hover() having no effect - Stack Overflow
I used a Docker container (because I'm not comfortable with essentially disabling the security sandbox by using the liberal permissions ...
Read more >
Puppeteer documentation - DevDocs
Puppeteer methods might throw errors if they are unable to fulfill a request. ... and then uses page.mouse to hover over the center...
Read more >
Page class - Puppeteer
mouse to hover over the center of the element. If there's no element matching selector , the method throws an error. isClosed(), Indicates...
Read more >
Build a Link Previewer with Puppeteer & Serverless Functions
emulateMediaFeatures ([ {name: 'prefers-color-scheme', value:'dark'} ]) // navigate to target URL and get page details and screenshot try{ ... } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found