click
Simulate real CDP mouse events to interact with elements by ref, selector, or coordinates. Handles canvas pixel-precise clicks and reports new tab openings with DOM diff for verification.
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 |
|---|---|---|---|
| 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. | |
| ref | No | A11y-Tree element ref (e.g. 'e5') — preferred over selector | |
| 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). | |
| selector | No | CSS selector (e.g. '#submit-btn') — fallback when ref is not available | |
| 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. |