click
Click elements using accessibility tree references, CSS selectors, text, or viewport coordinates. Dispatches real CDP mouse events and reports DOM changes automatically.
Instructions
Click an element by ref, CSS selector, or viewport coordinates. Dispatches real CDP mouse events (mouseMoved/mousePressed/mouseReleased). For canvas or pixel-precise targets, use x+y coordinates instead of ref. If the click opens a new tab, the response reports it automatically. The response already includes the DOM diff (NEW/REMOVED/CHANGED lines) — inspect those changes for success/failure signals instead of following up with evaluate to re-check state. If click fails with a stale-ref error, call view_page for fresh refs and retry. Avoid evaluate(querySelector + .click()) as default recovery — it bypasses the CDP pointer chain and hides real bugs. (Legitimate exception: explicitly testing synthetic JS event plumbing.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | A11y-Tree element ref (e.g. 'e5') — preferred over selector | |
| selector | No | CSS selector (e.g. '#submit-btn') — fallback when ref is not available | |
| text | No | Visible text to match (e.g. 'Submit'). Finds element by name in the A11y tree — no prior view_page needed. Prefers interactive elements (buttons, links). | |
| x | No | X coordinate (viewport pixels) — for canvas or pixel-precise clicks. Use with y instead of ref/selector. | |
| y | No | Y coordinate (viewport pixels) — for canvas or pixel-precise clicks. Use with x instead of ref/selector. | |
| wait_for_diff | No | When true, wait for the DOM diff synchronously before returning (slower but diff is in this response). Default: false — diff piggybacks on the next tool response. |