Octane
Octane

Reputation: 198

Puppeteer wait for page to fully load before proceeding

Here's my code. So basically I have an element in the page that I will click. Im not sure if waitForNavigation is the correct function to use here but I want the page to load fully before proceeding on to the next step.

I could use waitForSelector as a workaround, but what if I dont have a fixed selector that I can search?

    await Promise.all([
      this.page.waitForNavigation(),
      element.click()
    ])

Upvotes: 0

Views: 3419

Answers (1)

Christophe Marois
Christophe Marois

Reputation: 6719

Use options.waitUntil (doc)

await Promise.all([
  this.page.waitForNavigation({ waitUntil: 'networkidle2' }),
  element.click()
])

Upvotes: 2

Related Questions