puppeteer: Puppeteer: element is visible, yet `page.waitForSelector` says it is NOT
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??
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 16 (2 by maintainers)
Commits related to this issue
- Workaround to puppeteer/puppeteer#6389 — committed to invoice-collector/invoice-collector by LucBerge 2 years ago
might just be a shot in the dark but try setting the viewport to a full screen:
await page.setViewport({width: 1860, height: 1400});@cipri-tom the visibility check is just not part of the CSS selector and the general algorithm for waitForSelector is to wait for an element matching the selector and then for the other conditions. The use case for this it to wait for the element identified by the selector to be visible, not to find an element that is visible and matching the selector.