Skip to main content

键盘与鼠标

🌐 Keyboard & Mouse

Keyboard

browser_press_key

按一个键或按键组合。

🌐 Press a key or key combination.

参数类型必填描述
keystring要按的键

常用按键: EnterTabEscapeBackspaceDeleteArrowUpArrowDownArrowLeftArrowRightHomeEndPageUpPageDown

组合键: Control+a, Control+c, Control+v, Shift+Tab, Alt+F4

→ browser_press_key { key: "Enter" }         // submit form
→ browser_press_key { key: "Tab" } // move to next field
→ browser_press_key { key: "Escape" } // close modal
→ browser_press_key { key: "Control+a" } // select all text
→ browser_press_key { key: "ArrowDown" } // navigate dropdown

browser_type

在元素中输入文本。详情请参见 Forms

🌐 Type text into an element. See Forms for details.

鼠标(视觉模式)

🌐 Mouse (Vision mode)

当启用 视觉 功能(--caps=vision)时,这些工具可用。它们使用截图中的像素坐标,而不是快照中的元素引用。

🌐 These tools are available when the vision capability is enabled (--caps=vision). They use pixel coordinates from screenshots rather than element refs from snapshots.

browser_mouse_move_xy

参数类型是否必填描述
x数字X 坐标(像素)
y数字Y 坐标(像素)

浏览器_鼠标按下 / 浏览器_鼠标抬起

🌐 browser_mouse_down / browser_mouse_up

在当前位置按下或释放鼠标按钮。

🌐 Press or release the mouse button at the current position.

browser_mouse_wheel

参数类型必填描述
deltaX数字水平滚动(像素)
deltaY数字垂直滚动(像素,正值 = 向下)

browser_mouse_click_xy

在特定坐标点击,无需先移动。

🌐 Click at specific coordinates without needing to move first.

参数类型必填描述
x数字X 坐标
y数字Y 坐标
button字符串left(默认)、rightmiddle
clickCount数字点击次数(双击为 2)
delay数字按下与抬起之间的延迟(毫秒)
→ browser_mouse_click_xy { x: 150, y: 300 }
→ browser_mouse_click_xy { x: 150, y: 300, clickCount: 2 } // double-click

browser_mouse_drag_xy

从一个位置拖到另一个位置。

🌐 Drag from one position to another.

参数类型是否必需描述
startX数字起始 X 坐标
startY数字起始 Y 坐标
endX数字结束 X 坐标
endY数字结束 Y 坐标
→ browser_mouse_drag_xy { startX: 100, startY: 200, endX: 400, endY: 200 }

何时使用鼠标工具

🌐 When to use mouse tools

场景用途
点击按钮、链接或表单元素带引用的 browser_click(默认)
基于画布的应用(绘图、地图)带视觉的鼠标工具
无辅助功能的自定义 UI 控件带视觉的鼠标工具
精确像素目标的拖动交互带视觉的鼠标工具

对于大多数 web 应用,来自可访问性快照的引用比坐标更可靠。仅在可访问性树未显示所需元素时使用鼠标工具。

🌐 For most web applications, refs from accessibility snapshots are more reliable than coordinates. Use mouse tools only when the accessibility tree doesn't expose the elements you need.