DEV Community

Discussion on: Web Scraping — Scrape data from your instagram page with Nodejs, Playwright and Firebase.

Collapse
 
aleccc profile image
Aleccc • Edited

Worth noting that the documentation has alternatives to hard-coding the wait times (page.waitForTimeout). Some commands like fill and click have auto waits built-in. Or you can explicitly wait for an object to appear in the DOM.

// Playwright waits for #search element to be in the DOM
await page.fill('#search', 'query');
Enter fullscreen mode Exit fullscreen mode
// Wait for #search to appear in the DOM.
await page.waitForSelector('#search', { state: 'attached' });
Enter fullscreen mode Exit fullscreen mode

https://playwright.dev/path=docs%2Fcore-concepts.md&q=auto-waiting#version=master

Collapse
 
dnature profile image
Divine Hycenth

Hi Aleccc,

I've updated the article to use this approach as recommended in the docs. Thank you for pointing that out :)