From b4fbe5240481ed4ab5ee93d5d1202f9cd7ec982d Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 11 Mar 2024 12:48:48 -0700 Subject: [PATCH] core(full-page-screenshot): emit screenshot commands in parallel --- core/gather/gatherers/full-page-screenshot.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/gather/gatherers/full-page-screenshot.js b/core/gather/gatherers/full-page-screenshot.js index 31c4f34faa1d..37dbd47f1972 100644 --- a/core/gather/gatherers/full-page-screenshot.js +++ b/core/gather/gatherers/full-page-screenshot.js @@ -119,11 +119,13 @@ class FullPageScreenshot extends BaseGatherer { * @return {Promise} */ async _takeScreenshot(context) { - const metrics = await context.driver.defaultSession.sendCommand('Page.getLayoutMetrics'); - const result = await context.driver.defaultSession.sendCommand('Page.captureScreenshot', { - format: FULL_PAGE_SCREENSHOT_FORMAT, - quality: FULL_PAGE_SCREENSHOT_QUALITY, - }); + const [metrics, result] = await Promise.all([ + context.driver.defaultSession.sendCommand('Page.getLayoutMetrics'), + context.driver.defaultSession.sendCommand('Page.captureScreenshot', { + format: FULL_PAGE_SCREENSHOT_FORMAT, + quality: FULL_PAGE_SCREENSHOT_QUALITY, + }), + ]); const data = `data:image/${FULL_PAGE_SCREENSHOT_FORMAT};base64,` + result.data; return {