Mouse Click
Browser Sessions
Mouse Click
Simulate a mouse click on the session’s active page, by coordinates or by CSS selector.
POST
Mouse Click
Overview
The/browser/sessions/{id}/mouse/click endpoint dispatches a mouse click against the currently active page inside a browser session. It supports two modes:
- Coordinates — click at
(x, y)in viewport CSS pixels. - Selector — click the center of an element matched by a CSS selector. Waits for the element to be visible.
(x, y) or selector, never both.
Path Parameters
Browser session ID (UUID). Create via
POST /browser/sessions.Body
X coordinate in viewport CSS pixels. Required together with
y when selector is omitted.Y coordinate in viewport CSS pixels. Required together with
x when selector is omitted.CSS selector of the element to click. Mutually exclusive with
x/y. Clicks the center of the element’s bounding box.How long to wait (ms) for the selector to become visible. Ignored when using coordinates.
Which match to click when the selector resolves to multiple elements (0-based).
Mouse button to press. One of
left, right, middle, back, forward. The back and forward buttons map to the side buttons used for browser navigation on some sites.Modifier keys held for the duration of the click. Each value must be one of
Shift, Control, Alt, Meta.Number of clicks to issue at the same point. Capped at 10.
Example Request
Response
Success Response (200)
X coordinate actually clicked (in viewport CSS pixels). For selector mode, this is the center of the resolved element.
Y coordinate actually clicked (in viewport CSS pixels).
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — both coordinate and selector modes supplied, selector didn’t match, unknown button/modifier, or numClicks out of range. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found or not owned by the caller. |
503 | The browser session is temporarily unreachable. |
Notes
- Coordinate system: coordinates are viewport-relative in CSS pixels. On HiDPI pages, they do not need to be scaled by
devicePixelRatio— the browser handles that internally. - Selector mode: the endpoint waits up to
timeoutms for the first match to become visible, then clicks the center of its bounding box. Useindexto target the Nth match. - Modifiers:
holdKeysare held for the full duration of every click in a multi-click sequence.