News for hackers. Stuff that matters.
Re:Theheadless.dev – open source Puppeteer and Playwright kn... by gitgud on Wednesday August 19, 2020 @09:37AM (#24210202)
Puppeteer's Networkidle events are the easiest solution, and I've had no problems with networkidle0 (waits until there's 0 pending requests).

For a foolproof way, you could also just wait until the specific DOM node you want exists. Either by:

- Polling the DOM until it exists via; setTimeout/setInterval

- Using MutationObservers to check the DOM on every node change, until it's been added to the DOM

Re:Theheadless.dev – open source Puppeteer and Playwright kn... by jadell on Wednesday August 19, 2020 @09:56AM (#24210370)
You don't need to poll the DOM yourself. Puppeteer's page.waitForSelector() does this for you. You can specify a timeout of how long to wait.
Re:Theheadless.dev – open source Puppeteer and Playwright kn... by gitgud on Wednesday August 19, 2020 @06:48PM (#24217745)
Woah, yeah I hadn't heard of that part of the api before. Looks perfect for that usecase.