The page.waitForNavigation({waituntil:'networkidle2'}) would be waiting until time out if network has already been idled before invoke it.
See original GitHub issueFor examle:
await page.goto("https://www.aqistudy.cn/html/city_realtime.html?v=2.3", { waitUntil: "networkidle2" }); await page.type("#city", cities[i]); await page.tap("a#btnSearch"); await page.waitForNavigation({ waitUntil: "networkidle2" });
After the #btnSearch is tapped, the web uses javascript to access data to render the table.
I thought using waitForNavigation could get the right result. However, the page would always be waiting until time out. It doesn’t work as I expected.
How could I fix it?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:15 (3 by maintainers)
Top Results From Across the Web
How to get Puppeteer waitForNavigation Working after click
The function page.waitForNavigation() waits for navigation to begin and end. The navigation has already been initiated with page.click() .
Read more >Page.waitForNetworkIdle() method - Puppeteer
class Page { waitForNetworkIdle(options?: { idleTime?: number; timeout?: number; } ... Promise which resolves when network is idle. Previous. Page.
Read more >Navigation and loading | Playwright 中文文档
Page navigation can be either initiated by the Playwright call: ... Page load takes time retrieving the response body over the network, parsing, ......
Read more >5 - Auto-Waiting mechanism in Playwright with C# .NET
In this video, we will discuss the working Auto- Waiting mechanism of Playwright with C# .NET and how the actionability and retry-ability ...
Read more >How to make puppeteer wait for page to load - Urlbox
Taking a screenshot before the page has fully loaded will result in a bad screenshot where images are not loaded and styles have...
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
Not sure about your specific code and whether your click is “happening” on the right element to trigger navigation, but in general if you want to make sure you catch an expected navigation event, create the waitForNavigation promise (but do not await it yet) BEFORE you trigger the navigation, i.e. before the click, not after. And then “await” that created promise, otherwise sometimes it will have happened so fast you will miss it.
So something like:
调接口抓数据吧