screenshot_diff
Compare two screenshots (baseline vs actual) or capture a screenshot to identify visual differences, returning diff path, pixel count, ratio, and pass/fail status.
Instructions
Compare two screenshots (baseline vs actual) or capture a current screenshot and return a diff summary and artifact path. Supports element-scoped capture via selector; does not emit long screenshot descriptions.
中文详情:
用途:比较两张截图(baseline/actual)或捕获当前截图并返回差异摘要与产物路径,不输出长截图描述
何时使用:手动指定 baseline/actual 路径做差异对比时;测试前后页面状态对比时;元素级截图差异分析时;调试 visual_compare 流程时
输出:{ ok: boolean, diffPath: string, baselinePath: string, actualPath: string, diffPixels: number, diffRatio: number, passed: boolean, threshold: number }
参数:
baselinePath (string, 可选):基线截图路径
actualPath (string, 可选):实际截图路径,与 baselinePath 同时提供时直接对比
beforePath (string, 可选):baselinePath 的别名
afterPath (string, 可选):actualPath 的别名
selector (string, 可选):捕获时仅截取该元素区域
threshold (number, 可选):差异阈值,默认 0.01
name (string, 可选):产物名称,用于命名 diff 文件
错误:baselinePath 与 actualPath 都缺失且浏览器未启动抛出 'No screenshots to compare';文件不存在抛出 'File not found'
示例:{"baselinePath":"screenshots/login.png","actualPath":"screenshots/login-v2.png","threshold":0.005,"name":"login-diff"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| selector | No | ||
| afterPath | No | ||
| threshold | No | ||
| actualPath | No | ||
| beforePath | No | ||
| baselinePath | No |