ref (e1, e2, …). Use the ref from the latest snapshot — a ref from an older one returns 404 after the page changes.
CLI and cURL examples use $RT and browser b1 (Sessions).
Read the page
snapshot returns {url, title, viewport, rev, elements} — every visible
element the page offers for interaction (links, buttons, inputs, and anything
with a role, click handler, or tabindex), reduced to what a model needs: ref,
tag, role, accessible name, bounding box, enabled/visible, plus
href/text/input_type where they exist. Each snapshot re-issues the tab’s
refs.
viewport is {width, height}; rev increments on every snapshot of the
tab. A snapshot returns at most 500 elements. Each element in elements:
Point at an element
Every action takes atarget. A ref string ("e3") from the latest snapshot
is the common case — fast, and it pins the exact element the model saw. The
other forms reach elements without a snapshot:
Shorthand: TypeScript accepts
{x: 640, y: 420} and Python the tuple
(640, 420) for coords. On css targets, pierce: true searches through
shadow roots; any CSS selector also supports host >>> inner for one
explicit shadow-root hop. The CLI takes e3, css:…, text:…, xpath:…,
role:…, or x,y — and --target-json on action (--element-json on
screenshot) accepts the full target object for frame, pierce,
attrs, and inner, which the short string form cannot express.
Click and type
Click, double-click, hover, fill, type, press, hotkey, and scroll. Each call waits until the element is visible and stable, then waits for the page to settle. The result says whether it ran, whether the page navigated, and the URL afterward. An element that never becomes actionable fails with409 — the error names
the failed check (element is not actionable: visible, enabled,
editable, receives-events, or stable).
The examples use a small inline page so every target resolves:
Per-verb fields
Typing secrets
fill with secret_ref types the value of a secret without it ever reaching
your client, logs, or model context. The name is a secret key in an
Identity provider
attached to the runtime; a name that is not attached returns 400.
Run JavaScript on the page
evaluate runs a JavaScript expression in the page and returns
{value, error, is_error} (isError in TypeScript) — value is the result
as JSON. Use it for page data, DOM reads, or scroll positions the digest
doesn’t expose. Returned promises are awaited.
A thrown exception comes back as
is_error: true with the message in
error, not as an HTTP error.
Answer a dialog
alert, confirm, and prompt dialogs are dismissed automatically about four
seconds after they open, so an unanswered dialog never wedges the page. To
answer one yourself, call dialog while it is open — the call waits briefly
for a dialog to appear and returns 404 if none does. accept confirms
(true in the SDKs; omitted on the wire means dismiss), prompt_text fills a
prompt(), and auto_dismiss: true dismisses any open dialog immediately.
Work a form
Beyond click and type, the sameactions/{verb} route covers form controls
and file inputs: select picks an <option>, check/uncheck toggle
boxes, focus/blur move focus, scroll_into_view scrolls the element
into view, drag_to drags onto a drop_target, and upload sets a file
input’s paths (guest-side paths — ship files in with runtime.files first).
Every verb takes the same target contract and settle options as click.
file_chooser event on the events
stream — useful to confirm
the page accepted the files.
Use a fresh snapshot
- Act on fresh refs. Each snapshot re-issues the tab’s refs, and a ref
points at the element’s position in the DOM — after a navigation or a
re-render, snapshot again before acting. A ref the tab has never issued
returns
404. - If an action fails with
409, the message names the failing check —visible,enabled,editable,receives-events, orstable. The element is hidden, disabled, covered, or still animating; scroll it into view, wait, or passforceas a last resort. settle: false(--no-settle) skips the post-action wait — useful when an action starts a long navigation you’ll wait for withnavigateordesktop.wait_stableinstead.evaluateis full code execution in the page — treat the expression as code you ship, not as user input.