Snapshot the page for an agent
The page's accessibility tree as compact text with a ref on every node you can act on.
Snapshot selector of the page
Examples #
- Snapshot the page for an agent
Details #
@e1 link "Pull requests" href=/pulls
@e2 textbox "Search" [focused]
@e3 button "Save" [disabled]
mode picks how much of the page you get. interactive (the default) keeps only what can be acted on: links, buttons, fields, menus, checkboxes, with headings as landmarks. reader is the page as a person reads it: headings, paragraphs (cut at maxText characters, with a count of what was cut), list items and every control, grouped under the page's regions (main, a form, each fieldset, a section with a heading), each as an indented level. Navigation, asides and footers stay as regions but fold to one line of refs, ads and hidden elements go, and wrapper divs disappear. full is the whole tree. The older interactive: true and interactive: false still work and mean interactive and full.
main
@e3 heading "Repo" level=1
text "Some bold words"
Account
@e4 textbox "Name" value="Kyle"
@e5 checkbox "Agree" [checked]
selector scopes it to one element. The result is {text, refs, url, title}; refs maps e3 to its role, name and a selector.
Every selector param then accepts a ref: browser.click {selector: "@e3"}. A ref lives until the tab navigates; a stale one fails with "the page changed since the snapshot", and the step says to take a snapshot again. With url or html the snapshot is of a page nobody has open, where visibility and focus are unknown and left out.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
browser | one of | safari chrome front | ||
depth | number | , maxText: For reader: levels of regions (5 by default) and characters kept of one text line (600). | ||
html | text | |||
impersonate | one of | auto chrome safari none | ||
interactive | yes / no | , maxNodes: 6,000 nodes by default. | ||
into | text | The variable that receives the result. | ||
maxNodes | number | |||
maxText | number | |||
mode | one of | interactive reader full | interactive (the default), reader or full. | |
sample | any value | |||
selector | text | Scope to one element. | ||
signIn | text | |||
tab | any value | , browser, timeout. | ||
timeout | number | |||
url | text | , html, via, signIn, impersonate: A page nobody has open. | ||
via | one of | tab fetch auto |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Gotchas #
A snapshot is capped at 1 MB; a page with more says so in the step's note.