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.

Puppeteer: element is visible, yet `page.waitForSelector` says it is NOT

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 5.2.1
  • Platform / OS version: OS X
  • URLs (if applicable):
  • Node.js version: 10.22

What steps will reproduce the problem?

Please include code that reproduces the issue.

await page.waitForSelector(".test", {
  visible: true,
});

I’m setting headless: false.

I’m looking right at .test in the DOM of launched browser window.

And yet…

await page.waitForSelector(".test", {
  visible: true,
});

Never resolves. Why?

OK, Let’s try this another way…

const d = await page.waitForSelector(".test", {
  timeout: 1222,
});
debugger;
try {
  await d.click(".test");
} catch (e) {
  debugger;
  console.log(e);
}

Again…

Error: Node is either not visible or not an HTMLElement

I’m SEEING .test element with my eyes. It’s there.

WHY does this fail??

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
niveiniicommented, Sep 21, 2020

might just be a shot in the dark but try setting the viewport to a full screen:

await page.setViewport({width: 1860, height: 1400});

0reactions
OrKoNcommented, Aug 5, 2022

Generally, the could be multiple reasons for this to fail: 1) the element is outside of the viewport 2) there are multiple elements with the same selectors and the one that gets queried for is not visible 3) the element has zero width/height but has visible children. Without a specific repro it’s hard to say if there is a bug. Also, we have tests for this functions so it’s working in general, but I won’t rule out some edge cases. So please re-open the issue with a repro if it still happens in the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

puppeteer: how to wait until an element is visible?
I think you can use page.waitForSelector(selector[, options]) function for that purpose. const puppeteer = require('puppeteer'); ...
Read more >
Puppeteer Timing, waitForSelector - Cobalt Intelligence
Web scraping with Puppeteer where we learn how to do different kinds of timing, ... It'll say this note is not visible in...
Read more >
Puppeteer documentation - DevDocs
Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol. The Puppeteer API is...
Read more >
How to make puppeteer wait for page to load - Urlbox
Because sometimes it's not as easy as waiting for the Page load event! ... waitForSelector() to wait for an element to be present,...
Read more >
Puppeteer Timing, waitForSelector - YouTube
This is a video about Puppeteer Timing, waitForSelector. ... to use Puppeteer and need to wait for an element to be visible on...
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