Browse the docs

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 #

See what can be clicked
Do
  1. Snapshot the page for an agent
Open in Switchboard to try it

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 #

ParameterTypeRequiredValuesWhat it does
browserone ofsafari chrome front
depthnumber, maxText: For reader: levels of regions (5 by default) and characters kept of one text line (600).
htmltext
impersonateone ofauto chrome safari none
interactiveyes / no, maxNodes: 6,000 nodes by default.
intotextThe variable that receives the result.
maxNodesnumber
maxTextnumber
modeone ofinteractive reader fullinteractive (the default), reader or full.
sampleany value
selectortextScope to one element.
signIntext
tabany value, browser, timeout.
timeoutnumber
urltext, html, via, signIn, impersonate: A page nobody has open.
viaone oftab 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.