Documentation Index
Fetch the complete documentation index at: https://mintlify.com/l-xiaoshen/handstage/llms.txt
Use this file to discover all available pages before exploring further.
page.screenshot() captures the current state of a browser tab and returns a Buffer containing the encoded image. You can write that buffer to disk, pass it to an image-processing library, or attach it to a test report. All rendering happens inside Chrome via the CDP Page.captureScreenshot command.
Basic usage
ScreenshotOptions reference
All fields are optional. Pass them as a single object topage.screenshot(options).
| Option | Type | Default | Description |
|---|---|---|---|
type | "png" | "jpeg" | "png" | Output image format. |
quality | number | — | JPEG compression quality (0–100). Only valid when type is "jpeg". |
fullPage | boolean | false | Capture the full scrollable page, not just the viewport. Cannot be used together with clip. |
clip | { x, y, width, height } | — | Capture a sub-region in CSS pixels. Cannot be used together with fullPage. |
omitBackground | boolean | false | Replace the white background with transparency. Only meaningful for PNG. |
animations | "allow" | "disabled" | "allow" | Set to "disabled" to freeze CSS animations and Web Animations before capture. |
caret | "hide" | "initial" | "hide" | Set to "hide" to make text cursors invisible during capture. |
scale | "device" | "css" | "device" | "css" renders one pixel per CSS pixel; "device" uses the current device pixel ratio. |
mask | Locator[] | — | Locators whose matched elements are covered with a solid color before capture. |
maskColor | string | "#FF00FF" | Fill color used for masked elements (any valid CSS color string). |
style | string | — | Additional CSS text injected into every frame before capture and removed afterwards. |
path | string | — | If provided, Handstage writes the buffer to this file path automatically. |
timeout | number | — | Maximum capture duration in milliseconds. |
Examples
Save to a file
The simplest way to persist a screenshot is to passpath:
Buffer in case you need it for further processing.
Capture beyond the viewport
UsefullPage: true to scroll through the entire page content:
Crop to a specific region
Useclip to capture a rectangular sub-region in CSS pixels:
clip and fullPage are mutually exclusive. Passing both throws an error.Transparent PNG
SetomitBackground: true to remove the white background fill. The resulting PNG will have an alpha channel where no page content is rendered:
omitBackground only works with the "png" format. For JPEG, the background is always opaque.JPEG with quality control
Freeze animations before capture
Setanimations: "disabled" to finish or cancel all running CSS animations and Web Animations API animations before the screenshot is taken:
Mask sensitive elements
Pass locators tomask to cover matched elements with a solid color. This is useful for redacting personal data in test artifacts:
CSS pixel scale
Usescale: "css" to render one output pixel per CSS pixel, regardless of the device pixel ratio. This keeps screenshot dimensions predictable across machines: