Refs and snapshots
Agents act on elements through short refs such as @e1, not raw selectors.
Snapshots
Section titled “Snapshots”agent-browser-ff snapshot builds a compact, accessibility-style tree of the page and assigns refs to interactive and text-bearing elements.
- One line per element, indentation for nesting.
- Long text is truncated and invisible elements are omitted, so output stays cheap in tokens.
- Iframes and shadow DOM appear nested; use their refs as normal.
| Flag | Effect |
|---|---|
--full |
Complete tree, including elements the compact view hides |
--selector <sel> |
Snapshot only a subtree |
How a ref resolves
Section titled “How a ref resolves”Each ref maps internally to a stable Playwright locator. The priority order is:
- role + accessible name
data-testid- label or placeholder
- text
- CSS (last resort)
Generations and stale refs
Section titled “Generations and stale refs”Refs belong to a snapshot generation. Any navigation or major DOM change bumps the generation.
Using a ref from an older generation returns E_STALE_REF (exit 4) with a hint to re-run snapshot. agent-browser-ff never silently retargets a stale ref.
Raw selectors
Section titled “Raw selectors”For scripting, commands also accept prefixed selectors:
| Prefix | Example |
|---|---|
css= |
css=a.next |
text= |
text=Sign in |
role= |
role=button |
Agents should prefer refs. Use selectors for scripts and for scrape schemas.
Overlay exclusion
Section titled “Overlay exclusion”The --gui overlay is excluded from snapshots, screenshots (unless --with-overlay), and scraped data.