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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.