import { Page } from 'playwright' ; export interface ScreenshotOptions { fullPage : boolean ; type { boolean } memberof omitBackground : boolean ; } const mandatoryFullPageScreenshotOptions = { fullPage : true , } ; export const defaultFullPageScreenshotOptions = { fullPage : true , omitBackground : false , } ; export 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 ; }