Playwright CDP icon

Playwright CDP

Automate browser interactions using Playwright with remote browser via CDP

Get Screenshot

AI-generated

Summary

Capture a screenshot of the current page via Chrome DevTools Protocol and return binary image data.

Inputs

  • cdpEndpoint (required) — The CDP endpoint URL to connect to the remote browser. Can be HTTP or WebSocket URL (e.g., http://localhost:9222 or ws://localhost:9222/devtools/browser/xxx). Default: http://localhost:9222.
  • authentication — Authentication method for the CDP connection. Options: none or httpBasicAuth. Default: none.
  • url (required) — The URL to navigate to before capturing the screenshot. Required for getScreenshot, getPageContent, and getPDF operations.
  • dataPropertyName (required) — Name of the binary property in which to store the image or PDF data. Default: data.
  • imageType — The image type to use. PNG and JPEG are supported. Default: png. Only applicable for getScreenshot.
  • quality — The quality of the image, between 0-100. Not applicable to png images. Default: 100. Shown when imageType is jpeg.
  • fullPage — When true, takes a screenshot of the full scrollable page. Default: false. Shown for getScreenshot.
  • queryParameters — The query parameter to send. Default: {}. Shown for getScreenshot, getPageContent, and getPDF.
  • options — Additional options for screenshot generation. Includes device emulation, viewport dimensions, extra headers, file name, timeout, waitUntil condition, locale, timezone, geolocation, ignoreHTTPSErrors, JavaScript enabled state, and CSP bypassing. Default: {}.

Output shape

binary data stored in the property specified by dataPropertyName, accompanied by JSON metadata.

The operation returns a binary buffer encoded as image/png or image/jpeg based on the imageType parameter, along with response headers, status code, and the final navigated URL.

Examples

Example 1: Take a full-page PNG screenshot of example.com

Set cdpEndpoint to http://localhost:9222, url to https://example.com, dataPropertyName to screenshot, imageType to png, and fullPage to true.

Discussion