website/versioned_docs/version-24.40.0/api/puppeteer.page.screenshot.md
Captures a screenshot of this page.
class Page {
screenshot(
options: Readonly<ScreenshotOptions> & {
encoding: 'base64';
},
): Promise<string>;
}
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>
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<Uint8Array></h2>class Page {
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>;
}
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>