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.