playwright-fluent
Version:
Fluent API around playwright
24 lines (23 loc) • 840 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.takeFullPageScreenshotAsBase64 = exports.defaultFullPageScreenshotOptions = void 0;
const mandatoryFullPageScreenshotOptions = {
fullPage: true,
};
exports.defaultFullPageScreenshotOptions = {
fullPage: true,
omitBackground: false,
};
async function takeFullPageScreenshotAsBase64(page, options) {
if (!page) {
throw new Error(`Cannot take a screenshot of the full page because no browser has been launched`);
}
const screenshotOptions = {
...options,
...mandatoryFullPageScreenshotOptions,
};
const screenshot = await page.screenshot(screenshotOptions);
const result = screenshot.toString('base64');
return result;
}
exports.takeFullPageScreenshotAsBase64 = takeFullPageScreenshotAsBase64;
;