Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async extendWithPageScreenshot(error) {
if (!this._config.screenshotOnReject || error.screenshot || this._screenshotTaken) {
return error;
}
this._screenshotTaken = true;
this._browser.setHttpTimeout(this._config.screenshotOnRejectTimeout);
try {
const {value: base64} = await this._browser.publicAPI.screenshot();
const size = Image.fromBase64(base64).getSize();
error = _.extend(error, {screenshot: {base64, size}});
} catch (e) {
logger.warn(`WARN: Failed to take screenshot on reject: ${e}`);
}
this._browser.restoreHttpTimeout();
return error;
}
};
.then((screenData) => {
const image = Image.fromBase64(screenData.value);
return this._applyCalibration(image);
});
}