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.

[BUG] waitForSelector can not work

See original GitHub issue

Context:

  • 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Dec 10, 2020

Looks like Playwright served you well! 🔥

1reaction
Fanlalalacommented, Dec 10, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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