Puppeteer: element is visible, yet `page.waitForSelector` says it is NOT
See original GitHub issueSteps 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:
- Created 3 years ago
- Reactions:3
- Comments:12 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

might just be a shot in the dark but try setting the viewport to a full screen:
await page.setViewport({width: 1860, height: 1400});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.