0

Does page.goto(url, {waitUntil: 'domcontentloaded'}) actually wait until Javascript has finished manipulating the DOM? Like for instance on a SPA? If not, how do I find out when the DOM is ready?

To wait for 'networkidle2' seems rather inefficient...

Thx!

Chris
  • 3
  • 3
  • 1
    The `networkidle0` and `networkidle2` are introduced exactly to deal with single-page apps, while `domcontentloaded` is not optimal for SPA-s (network connections can be active even if this event is fired already). Have you tried `page.waitForSelector`? I think all options are discussed in this question: https://stackoverflow.com/questions/52497252/puppeteer-wait-until-page-is-completely-loaded – theDavidBarton Jul 23 '20 at 12:45
  • I would feel most comfortable if I knew the DOM is stable and is not being updated by any running script anymore... As I understand, 'networkidle' doesn't address this... – Chris Jul 24 '20 at 13:18
  • No, it doesn't address DOM readiness; however: in case of SPA-s you can be sure that all the elements are available if you use `networkidle0`. But it will take a lot more time than either `networkidle2` or `domcontentloaded` (in case of a non-SPA page). – theDavidBarton Jul 24 '20 at 13:30

0 Answers0