Skip to main content

Keyboard & Mouse

Keyboard

browser_press_key

Press a key on the keyboard. The key is pressed on the page, not on a specific element — focus the element first (for example with browser_click) if it matters.

ParameterTypeRequiredDescription
keystringyesName of the key to press or a character to generate, such as ArrowLeft or a

Common keys: Enter, Tab, Escape, Backspace, Delete, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown

Key combinations: 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

Type text into an element. See Forms for details.

To type key by key rather than filling the whole value at once, use browser_type with slowly: true.

Mouse (Vision mode)

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

ParameterTypeRequiredDescription
xnumberyesX coordinate
ynumberyesY coordinate

browser_mouse_down / browser_mouse_up

Press or release a mouse button at the current position.

ParameterTypeRequiredDescription
buttonstringnoleft (default), right, or middle

browser_mouse_wheel

ParameterTypeRequiredDescription
deltaXnumbernoHorizontal scroll, defaults to 0
deltaYnumbernoVertical scroll, defaults to 0 (positive = down)

browser_mouse_click_xy

Click at specific coordinates without needing to move first.

ParameterTypeRequiredDescription
xnumberyesX coordinate
ynumberyesY coordinate
buttonstringnoleft (default), right, or middle
clickCountnumbernoNumber of clicks, defaults to 1
delaynumbernoTime between mouse down and mouse up in milliseconds, defaults to 0
→ 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 the left mouse button from one position to another.

ParameterTypeRequiredDescription
startXnumberyesStart X coordinate
startYnumberyesStart Y coordinate
endXnumberyesEnd X coordinate
endYnumberyesEnd Y coordinate
→ browser_mouse_drag_xy { startX: 100, startY: 200, endX: 400, endY: 200 }
tip

Pass boxes: true to browser_snapshot (or start the server with --snapshot-boxes) to get each element's [box=x,y,width,height] in the snapshot. That gives coordinates without a screenshot round-trip.

When to use mouse tools

ScenarioUse
Clicking a button, link, or form elementbrowser_click with a ref (default)
Canvas-based apps (drawing, maps)Mouse tools with vision
Custom UI controls without accessibilityMouse tools with vision
Drag interactions on pixel-precise targetsMouse tools with vision

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.