puppeteer 等页面加载完再截图,就这个demo

小哈
  • 214
const puppeteer = require('puppeteer');
const path = require('path');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('xxxxxxxx');
  await page.screenshot({path: path.join(__dirname,'example.png'),fullPage: true, omitBackground: true });

  await browser.close();
})();

页面是用react写的,其中有个Loading页面,每次截图都是loading,不是loading结束后的。

回复
阅读 5k
1 个回答
✓ 已被采纳

waitForNavigation

宣传栏