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] waitFor set timeout doesn't work in headless mode but does work in headed mode

See original GitHub issue

Context:

  • Playwright Version: ^1.18.1
  • Operating System: Linux
  • Node.js version: v16.13.1
  • Browser: Chromium

Code Snippet

test('2.4 - Delete a new sandbox', async ({ page }) => {
  page.setDefaultTimeout(600000);
  const APP = 'baseline-sandbox-delete';
  const SANDBOX = 'development';

  const applicationPage = new ApplicationPage(page);
  await expect(applicationPage.getApplicationTitle(APP)).toBeVisible();
  const sandbox = await applicationPage.getSandboxOrBranchElement(SANDBOX);
  const sandboxExists = (await sandbox.count()) > 0;
  if (!sandboxExists) {
    await applicationPage.createSandbox(SANDBOX);
    await expect(applicationPage.creatingSandboxOrBranchText).toBeVisible();
    const loading = applicationPage.creatingSandboxOrBranchText;
    await loading.waitFor({ state: 'hidden', timeout: 600000 });
  }
  await applicationPage.deleteSandbox(SANDBOX);
  await expect(sandbox).toHaveCount(0);
});

Describe the bug

Wen running the test as described above in headed mode with PWDEBUG=1 I can see that the test pauses until the loading element disappears and then continues with the deletion part which is what I expect. However when running the test in headless mode it seems to ignore the timeout thus resulting in the test to fail because the loading state is still visible at that time.

Error:

`Timeout of 30000ms exceeded.

Pending operations:
  - locator.waitFor at tests/applications/applications.spec.ts:87:19

locator.waitFor: Target closed
=========================== logs ===========================
waiting for selector "p:has-text("%")" to be hidden
  selector resolved to visible <p class="sc-TBWPX joiGzv">0%</p>
============================================================

  85 |     await expect(applicationPage.creatingSandboxOrBranchText).toBeVisible();
  86 |     const loading = applicationPage.creatingSandboxOrBranchText;
> 87 |     await loading.waitFor({ state: 'hidden', timeout: 600000 });
     |                   ^
  88 |   }
  89 |   await applicationPage.deleteSandbox(SANDBOX);
  90 |   await expect(sandbox).toHaveCount(0);

`

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
yaml-nscommented, Jul 6, 2022

Same problem. Code works headed mode but doesn’t in headless mode.

  • Playwright Version: 1.23.0
  • Operating System: Linux / Windows
  • Python : 3.7
  • Browser: Chromium
response = page.goto(source)
page.wait_for_selector('a[href="' + url + '"]')
result = bout_scrap(page.content(), url)
Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "a[href="https://en.wikipedia.org/wiki/UEFA_European_Championship"]"
============================================================

0reactions
pavelfeldmancommented, Apr 25, 2022

We need more information to act on this report. Please file a new one and link to this issue when you get back to it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

waitForSelector with Puppeteer not responding only in ...
When I run puppeteer with headless: false it successfully waits for the selector nameField however with headless: true I just get the timeout...
Read more >
How to Get Selenium to Wait for Page Load After a Click
Ever wondered how to set up Selenium so it should just wait until the page has completed loading after you click on a...
Read more >
Browser - MarketSquare
Browser library is a browser automation library for Robot Framework. This is the keyword documentation for Browser library.
Read more >
SeleniumBase Docs
A complete framework for end-to-end testing with Python, pytest, behave-BDD, and WebDriver.
Read more >
From capybara-webkit to Headless Chrome and ChromeDriver
While capybara-webkit did the job for quite some time, the change to a more modern alternative (Chrome's headless mode) will make tests more ......
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