diff --git a/src/renderers/chrome/index.js b/src/renderers/chrome/index.js index 9ee03f3..7b55de1 100644 --- a/src/renderers/chrome/index.js +++ b/src/renderers/chrome/index.js @@ -114,7 +114,7 @@ export class ChromeRenderer extends Renderer { } async renderPage(page, options = {}) { - let { path: filepath, type } = options; + let { path: filepath, type, waitForNavigation } = options; let buffer; if (!isString(type)) { @@ -122,6 +122,21 @@ export class ChromeRenderer extends Renderer { type = type.length > 0 ? type : 'html'; } + if (waitForNavigation !== null && waitForNavigation !== undefined) { + if (waitForNavigation === false) { + return; + } else if (waitForNavigation === Object(waitForNavigation)) { + await page._chromePage.waitForNavigation(waitForNavigation); + } else { + await page._chromePage.waitForNavigation({ + waitUntil: 'networkidle', + networkIdleInflight: 0, + timeout: 0 + }); + } + delete options.waitForNavigation; + } + switch (type) { case 'html': buffer = await page._chromePage.content();