Categories
JavaScript Answers

How to wait for all images to load then take screenshot with Puppeteer?

Spread the love

Sometimes, we want to wait for all images to load then take screenshot with Puppeteer.

In this article, we’ll look at how to wait for all images to load then take screenshot with Puppeteer.

How to wait for all images to load then take screenshot with Puppeteer?

To wait for all images to load then take screenshot with Puppeteer, we can use the waitUntil option with the page.goto method.

For instance, we write

await page.goto("https://www.example.com/", { waitUntil: "networkidle0" });

to go to https://www.example.com/ with goto and set the waitUntil option to 'networkidle0' to wait for everything to finish loading before resolving the returned promise.

Conclusion

To wait for all images to load then take screenshot with Puppeteer, we can use the waitUntil option with the page.goto method.

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 *