Puppeteer wait until page is completely loaded

后端 未结 7 1239
梦如初夏
梦如初夏 2020-12-01 06:40

I am working on creating PDF from web page.

The application on which I am working is single page application.

I tried many options and suggestion on https://

7条回答
  •  萌比男神i
    2020-12-01 06:44

    In some cases, the best solution for me was:

    await page.goto(url, { waitUntil: 'domcontentloaded' });
    

    Some other options you could try are:

    await page.goto(url, { waitUntil: 'load' });
    await page.goto(url, { waitUntil: 'domcontentloaded' });
    await page.goto(url, { waitUntil: 'networkidle0' });
    await page.goto(url, { waitUntil: 'networkidle2' });
    

    You can check this at puppeteer documentation: https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-pagewaitfornavigationoptions

提交回复
热议问题