browser_screenshot_element
Capture a screenshot of a page element using its CSS selector, returning the file path and dimensions. Optionally add padding to expand the capture area.
Instructions
Screenshot a specific page element located by CSS selector, returning the artifact path and dimensions. Supports padding to expand the captured area.
中文详情:
用途:对指定 CSS 选择器元素截图,截取该元素的可见区域,返回截图路径和尺寸信息
何时使用:组件级截图取证时;视觉对比前截取元素图时;bug 报告附带局部截图时;多元素单独留档时
输出:{ ok: boolean, path: string, name: string, selector: string, width: number, height: number, timestamp: string }
参数:
selector (string, 必填):目标元素的 CSS 选择器
padding (number, 可选):截图区域周围的 padding,单位像素,默认 0
name (string, 可选):截图文件名(不含扩展名),默认自动生成
错误:selector 无匹配抛出 'element not found';元素不可见抛出 'element not visible'
示例:{"selector":".user-avatar","padding":10,"name":"avatar-component"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | 截图文件名(不含扩展名),默认自动生成 | |
| padding | No | 截图区域周围的padding,单位像素,默认0 | |
| selector | Yes | 目标元素的CSS选择器 |