How to check if the puppeteer is finish downloading the file

Viewed 1139

I'm using this code to download files. I just hide the urls for security reasons. In the code below how can I check if the puppeteer has finished downloading the file

const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();

await page.setDefaultNavigationTimeout(0);
await page.goto('https://');
await page.waitForSelector('#aaa');
await page.goto('https://');
await page.waitForSelector('#bbb');
await page.goto('https://');
1 Answers

Please see the Puppeteer documentation as this is a very basic first step when working with Puppeteer.

page.waitForNavigation({ waitUntil: 'networkidle0' })

This will: "consider navigation to be finished when there are no more than 0 network connections for at least 500 ms."

https://pptr.dev/

Related