[BUG] waitForSelector can not work
See original GitHub issueContext:
- Playwright Version: 1.6.1
- Operating System:
- Windows 10 Enterprise 20H2 19042.685
- Ubuntu 16.04
- Node.js version: 12.13.0
- Browser: Chromium
- Extra:
- jest: 26.6.3
- typescript: 4.0.5
- ts-jest: 26.4.4
Code Snippet
Below is simplified code
const {chromium, webkit, firefox} = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await (await browser.newContext({
viewport: {
width: 1920,
height: 1080
}
})).newPage();
const selector = ".test-selector";
// It works
const elHandle = await page.$(selector);
// Timeout error, stable reproduce
const elHandle = await page.waitForSelector(selector);
// It works
const elHandle = await page.waitForSelector(selector, { state: "attached" });
})();
Describe the bug
We’re sure that selected element has content by screenshots, and we check the API document to make sure it has the bounding box by printing $(selector).getBoundingClientRect()
in the console on headless: false
mode.
So we suspect it’s a bug caused by waitForSelector
with default options.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
node.js - Puppeteer waitForSelector not working as expected
So I uderstand that document.querySelector('#searchboxinput') == undefined while I suppose that it cannot be possible as it's executed when ...
Read more >waitForSelector not working as intended? · Issue #2598 - GitHub
Response from the server can take time, which is why I added the timeout: 1000 . With await page.waitForSelector(sel('test-project'), { timeout: ...
Read more >Page.waitForSelector() method - Puppeteer
Promise which resolves when element specified by selector string is added to DOM. Resolves to null if waiting for hidden: true and selector...
Read more >Puppeteer Timing, waitForSelector - Cobalt Intelligence
This is a video about Puppeteer Timing, waitForSelector. ... It'll say this note is not visible in the page. Can't do it.
Read more >puppeteer waitforselector - Unisa
waitForSelector will throw "timeout error" event if there is ele. Here is a (pseudo-code) ... Puppeteer: waitForSelector followed by click is not working...
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 FreeTop 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
Top GitHub Comments
Looks like Playwright served you well! 🔥
Hi @aslushnikov & @Joouis , this issue is caused by elm.getBoundingClientReact().width = 0. So selectorEvaluator.isVisible(https://github.com/microsoft/playwright/blob/b67e0221117cc0dca11ae3717b70442649078afe/src/server/injected/selectorEvaluator.ts#L538) will return false. This only happens on office-ui-fabric-react panel element. We do not think it is playwright’s bug.