screenshot
Capture a screenshot of a window or DOM element.
Bridge
Bridge required only when using --selector. Full window screenshots (--title only) work without a bridge.
Usage
Options
| Option | Description | Default |
|---|---|---|
-s, --selector <css> |
CSS selector — screenshot just this element (requires bridge) | — |
-t, --title <regex> |
Window title to match (auto-discovered from bridge if omitted) | — |
-o, --output <path> |
Output file path | screenshot-<timestamp>.png |
--format <png\|jpg> |
Output format | png |
--max-width <number> |
Resize to max width (preserves aspect ratio) | — |
--json |
Output structured JSON metadata | — |
--port <number> |
Bridge port (auto-discover if omitted) | — |
--token <string> |
Bridge token (auto-discover if omitted) | — |
Examples
Full window screenshot
DOM element screenshot
Resized element screenshot
JSON metadata output
{
"path": "/tmp/header.png",
"format": "png",
"size": 45231,
"selector": ".header",
"windowTitle": null
}
JPEG format
How It Works
When --selector is used:
- Bridge evaluates
getBoundingClientRect()for the CSS selector - Bridge reports viewport size (
window.innerWidth/innerHeight) - Platform adapter captures the full window
- Crop region is computed: element rect + decoration offset (title bar, borders)
- ImageMagick
convertcrops to the element bounds - Optional resize with
--max-width
When only --title is used, the full window is captured directly without cropping.
Tips
- Use
dom --depth 2first to find the right CSS selector - The
--max-widthflag is useful for keeping screenshots manageable for AI agents - Without
--title, the tool auto-discovers the window title from the bridge viadocument.title