Back to Puppeteer

Page.screenshot() method

docs/api/puppeteer.page.screenshot.md

19.2.21.6 KB
Original Source

Page.screenshot() method

<h2 id="overload-1">screenshot(): Promise&lt;string&gt;</h2>

Captures a screenshot of this page.

Signature

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

Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

options

</td><td>

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

</td><td>

Configures screenshot behavior.

</td></tr> </tbody></table>

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.

<h2 id="overload-2">screenshot(): Promise&lt;Uint8Array&gt;</h2>

Signature

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

Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

options

</td><td>

Readonly<ScreenshotOptions>

</td><td>

(Optional)

</td></tr> </tbody></table>

Returns:

Promise<Uint8Array>