From 731d77f30d6c2f177bec3e70333df2128b39b588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=A2=E6=AF=94=E5=B0=8F=E9=87=91=E5=88=9A?= <2890636389@qq.com> Date: Thu, 25 Jan 2024 21:33:37 +0800 Subject: [PATCH] Fix `fullPage` option (#116) --- index.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6b15b1a..d2f9c5f 100644 --- a/index.js +++ b/index.js @@ -377,14 +377,14 @@ const internalCaptureWebsiteCore = async (input, options, page, browser) => { if (screenshotOptions.fullPage) { // Get the height of the rendered page const bodyHandle = await page.$('body'); - const bodyBoundingHeight = await bodyHandle.boundingBox(); + const bodyBoundingBox = await bodyHandle.boundingBox(); await bodyHandle.dispose(); // Scroll one viewport at a time, pausing to let content load const viewportHeight = viewportOptions.height; let viewportIncrement = 0; - while (viewportIncrement + viewportHeight < bodyBoundingHeight) { - const navigationPromise = page.waitForNavigation({waitUntil: 'networkidle0'}); + while (viewportIncrement + viewportHeight < bodyBoundingBox.height) { + const navigationPromise = page.waitForNetworkIdle(); /* eslint-disable no-await-in-loop */ await page.evaluate(_viewportHeight => { /* eslint-disable no-undef */ diff --git a/package.json b/package.json index 268aade..f89ad95 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "@cliqz/adblocker-puppeteer": "^1.26.11", "file-url": "^4.0.0", - "puppeteer": "^21.5.0", + "puppeteer": "^21.9.0", "tough-cookie": "^4.1.3" }, "devDependencies": {