browser_scroll
Scroll a webpage to a specific element or by pixel coordinates, supporting auto or smooth behavior to trigger lazy-loaded content or bring elements into view for testing.
Instructions
Scroll the page or to a specific element. Supports scrollIntoView for targeting an element and pixel-based x/y scrolling with auto/smooth behavior.
中文详情:
用途:滚动页面到指定位置,支持滚动到指定元素(scrollIntoView)或按像素值(x/y)滚动
何时使用:需要触发懒加载内容时;将目标元素滚动到可视区域时;测试无限滚动分页时;截图前确保元素可见时
输出:{ ok: boolean, scrollX: number, scrollY: number, scrolledTo: string, timestamp: string }
参数:
selector (string, 可选):要滚动到的目标元素选择器,与 scrollIntoView 配合使用
scrollIntoView (boolean, 可选):是否滚动到 selector 指定的元素,默认 true(指定 selector 时)
x (number, 可选):横向滚动像素值(不指定 selector 时使用)
y (number, 可选):纵向滚动像素值(不指定 selector 时使用)
behavior (string, 可选):滚动行为,可选 auto/smooth,默认 auto
错误:selector 无匹配抛出 'element not found';selector 与 x/y 同时提供时以 selector 为优先
示例:{"selector":"#footer","behavior":"smooth"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | 横向滚动像素值(不指定 selector 时使用) | |
| y | No | 纵向滚动像素值(不指定 selector 时使用) | |
| behavior | No | 滚动行为,默认 auto | |
| selector | No | 要滚动到的目标元素选择器,与 scrollIntoView 配合使用 | |
| scrollIntoView | No | 是否滚动到 selector 指定的元素,默认 true(指定 selector 时) |