I am using Puppeteer to try to take a screenshot of a website after all images have loaded but can\'t get it to work.
Here is the code I\'ve got so far, I am using h
Another option, actually evaluate to get callback when all images were loaded
This option will also work with setContent that doesn't support the wait networkidle0
option
await page.evaluate(async () => {
const selectors = Array.from(document.querySelectorAll("img"));
await Promise.all(selectors.map(img => {
if (img.complete) return;
return new Promise((resolve, reject) => {
img.addEventListener('load', resolve);
img.addEventListener('error', reject);
});
}));
})