Skip to main content
Version: Next

Page.screenshot() method

screenshot(): Promise<string>

Captures a screenshot of this page.

Signature

class Page {
screenshot(
options: Readonly<ScreenshotOptions> & {
encoding: 'base64';
}
): Promise<string>;
}

Parameters

Parameter

Type

Description

options

Readonly<ScreenshotOptions> & { encoding: 'base64'; }

Configures screenshot behavior.

Returns:

Promise<string>

Remarks

While a screenshot is being taken in a BrowserContext, the following methods will automatically wait for the screenshot to finish to prevent interference with the screenshot process: BrowserContext.newPage(), Browser.newPage(), Page.close().

Calling Page.bringToFront() will not wait for existing screenshot operations.

screenshot(): Promise<Buffer>

Signature

class Page {
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Buffer>;
}

Parameters

Parameter

Type

Description

options

Readonly<ScreenshotOptions>

(Optional)

Returns:

Promise<Buffer>