Categories
JavaScript Answers

How to wait until page is completely loaded with Puppeteer and JavaScript?

Spread the love

Sometimes, we want to wait until page is completely loaded with Puppeteer and JavaScript.

In this article, we’ll look at how to wait until page is completely loaded with Puppeteer and JavaScript.

How to wait until page is completely loaded with Puppeteer and JavaScript?

To wait until page is completely loaded with Puppeteer and JavaScript, we call goto with an object with the waitUntil property.

For instance, we write

await page.goto(url, { waitUntil: "domcontentloaded" });

to call page.goto with the url and { waitUntil: "domcontentloaded" } to navigate to the url and wait until the whole page is loaded by setting waitUntil to 'domcontentloaded'.

Conclusion

To wait until page is completely loaded with Puppeteer and JavaScript, we call goto with an object with the waitUntil property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *