Skip to main content

snapshot

Capture and compare visual snapshots for regression testing. Take a baseline set of screenshots, make changes, then compare — snapshot computes per-page pixel diffs and flags regressions against a threshold.

Synopsis

snapshot {action: "screenshot", proxy_id: "dev"}
snapshot {action: "baseline", name: "before-refactor", pages: [...]}
snapshot {action: "compare", baseline: "before-refactor", pages: [...]}
snapshot {action: "list"}

Actions

ActionDescription
screenshotCapture the current page of a running proxy (writes a PNG, returns the path)
baselineCreate a named baseline from a set of screenshots
compareCompare current screenshots against a baseline and report diffs
listList all available baselines
getGet details of a specific baseline
deleteDelete a baseline

Parameters

ParameterTypeUsed byDescription
actionstringallOne of the actions above
namestringbaseline / compare / delete / get; optional for screenshotBaseline or screenshot name
baselinestringcompareBaseline name to compare against
pagesarraybaseline / comparePages to capture: [{url, viewport, screenshot_data}]
diff_thresholdfloatcompareDiff sensitivity 0.0–1.0 (default 0.01)
proxy_idstringscreenshotProxy whose current page to capture (preferred)
idstringscreenshotAlias for proxy_id
selectorstringscreenshotCSS selector to capture (default: full viewport)
full_pageboolscreenshotCapture the full scrollable page (default: viewport only)

Capturing a Screenshot

snapshot {action: "screenshot", proxy_id: "dev"}
snapshot {action: "screenshot", proxy_id: "dev", name: "homepage", full_page: true}
snapshot {action: "screenshot", proxy_id: "dev", selector: ".header"}

The screenshot action requires daemon mode (it routes through the daemon's proxy session). It writes a PNG and returns its path.

Baseline / Compare Workflow

// 1. Capture a baseline before changes
snapshot {action: "baseline", name: "before-refactor",
pages: [{url: "/", viewport: {width: 1920, height: 1080}, screenshot_data: "base64..."}]}

// 2. After changes, compare
snapshot {action: "compare", baseline: "before-refactor",
pages: [{url: "/", viewport: {width: 1920, height: 1080}, screenshot_data: "base64..."}]}

Comparison reports per-page diff_percentage, a saved diff-image path, and a summary:

{
"baseline_name": "before-refactor",
"pages": [
{"url": "/", "diff_percentage": 2.5, "has_changes": true, "diff_image_path": "...", "description": "Moderate changes (2.50%)"}
],
"summary": {"total_pages": 1, "pages_changed": 1, "average_diff": 2.5, "has_regressions": true}
}

A page counts as changed when its diff exceeds diff_threshold.

See Also