Skip to main content

Interaction

Click, hover, drag, and select elements using refs from accessibility snapshots.

ToolDescription
browser_clickClick an element
browser_hoverHover over an element
browser_dragDrag and drop between elements
browser_select_optionSelect a dropdown option
browser_resizeResize the browser window

Targeting elements

Every interaction tool takes a ref parameter that identifies the target element. Refs come from accessibility snapshots returned by browser_snapshot or after navigation. Take a snapshot first, find the element's [ref=...] tag, then pass that ref to the interaction tool.

→ browser_snapshot
- button "Submit" [ref=e12] ← ref is "e12"
- link "Learn more" [ref=e15] ← ref is "e15"

→ browser_click { ref: "e12" } // clicks the Submit button

browser_click

Click an element on the page.

ParameterTypeRequiredDescription
refstringyesElement reference from snapshot
→ browser_click { ref: "e12" }       // clicks the Submit button
→ browser_click { ref: "e15" } // clicks the Learn more link

browser_hover

Hover over an element to trigger tooltips, dropdowns, or hover states.

ParameterTypeRequiredDescription
refstringyesElement reference from snapshot
→ browser_hover { ref: "e3" }
→ browser_snapshot
// Snapshot now shows the revealed dropdown menu
- menuitem "Profile" [ref=e20]
- menuitem "Settings" [ref=e21]
- menuitem "Logout" [ref=e22]

browser_drag

Drag one element and drop it onto another.

ParameterTypeRequiredDescription
startRefstringyesElement to drag
endRefstringyesElement to drop onto
→ browser_drag { startRef: "e5", endRef: "e10" }

browser_select_option

Select one or more options in a <select> dropdown.

ParameterTypeRequiredDescription
refstringyesThe select element ref
valuesstring[]yesValues or labels to select
→ browser_snapshot
- combobox "Country" [ref=e7]

→ browser_select_option { ref: "e7", values: ["United States"] }

browser_resize

Resize the browser window.

ParameterTypeRequiredDescription
widthnumberyesWidth in pixels
heightnumberyesHeight in pixels
→ browser_resize { width: 375, height: 812 }    // mobile viewport
→ browser_resize { width: 1920, height: 1080 } // desktop

Workflow: filling a form and submitting

→ browser_snapshot
- textbox "Email" [ref=e3]
- textbox "Password" [ref=e5]
- combobox "Role" [ref=e7]
- button "Sign up" [ref=e9]

→ browser_type { ref: "e3", text: "alice@example.com" }
→ browser_type { ref: "e5", text: "s3cret!" }
→ browser_select_option { ref: "e7", values: ["Admin"] }
→ browser_click { ref: "e9" }

→ browser_snapshot
- heading "Welcome, Alice!" [level=1]
- text: "Your account has been created."