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.

page.waitForNavigation hangs forever

See original GitHub issue

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem? Full code as follows, just trying to go to 10 pages by clicking the next link on each page.

const pptr = require('puppeteer');

async function main() {
  const br = await pptr.launch({headless: false, defaultViewport: null});
  const page = await br.newPage();

  await page.goto(
    'https://www.escentual.com/catalogsearch/result/?q=face',
    {waitUntil: 'networkidle2'}
  );

  for (var i=0; i<10; ++i) {
    await Promise.all([
      page.waitForNavigation({waitUntil: 'load', timeout: 100000}),
      page.click('#adj-nav-container > div.category-products > div.toolbar > div > div.amount > div > ol > li.next > a'),
    ]);
    console.log(`waited, url=${page.url()}`);
  }
  await br.close();
}

main();

What is the expected result? I was expecting the above code could go to 10 pages by clicking the next link on each page.

What happens instead? However, the above code gets stuck at 2nd page forever, waiting waitForNavigation to finish forever.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

3reactions
ecolsscommented, Feb 15, 2020

If I remove or replace the page.waitForNavigation in the above code, it works. So I thought maybe there is no navigation event happening at all after the click?

But this speculation doesn’t make sense, since according to the waitForNavigation documentation, if the page navigates to a new url, it should have a navigation event, right?

0reactions
stale[bot]commented, Jul 24, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

waitForNavigation hanging, even though page was loaded
According to Puppeteer documentation proper pattern for clicking on submit and waiting for navigation is like this: await Promise.all([ page ...
Read more >
Page.waitForNavigation() method - Puppeteer
Waits for the page to navigate to a new URL or to reload. It is useful when you run code that will indirectly...
Read more >
navigation failed because page was closed! - You.com
waitForNavigation : Navigation failed because page was closed! ... are failing just because load event never happen (because some requests pending forever).
Read more >
Introduction to the Jest and Puppeteer Timeouts - Medium
page.waitForNavigation. Also, you can specify the custom timeout per each page ... setDefaultNavigationTimeout takes priority over page.
Read more >
Answers to All The Top Questions For Playwright Testing
Q: When a page is opened using browser context, is the page ... Q: Why is waitForNavigation needed if Playwright has an auto-wait...
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