0

I'm experimenting with JavaScript and puppeteer and when I go onto a site I have set it up so it takes a screenshot, but the problem is some elements of the website haven't loaded in when it takes the screenshot, is there anything I can do to add a delay?

Maloni
  • 27
  • 4
  • Does this answer your question? [How to execute a function when page has fully loaded?](https://stackoverflow.com/questions/1033398/how-to-execute-a-function-when-page-has-fully-loaded) – Philip Raath Oct 22 '20 at 18:46
  • I tried deploying it in my code couldn't get it to work. The error I got was that window is not defined and i have no idea how to fix this. – Maloni Oct 22 '20 at 18:55

1 Answers1

1

Check my answer at: https://stackoverflow.com/a/57677369/10251383

Try this options with your page.goto():

await page.goto(url, { waitUntil: 'load' });
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.goto(url, { waitUntil: 'networkidle0' });
await page.goto(url, { waitUntil: 'networkidle2' });
Eduardo Conte
  • 1,145
  • 11
  • 18