Snapshots
The snapshot command returns the accessibility tree with refs for AI-friendly interaction.
Options
Filter output to reduce size:
agent-browser snapshot # Full accessibility tree
agent-browser snapshot -i # Interactive elements only
agent-browser snapshot -c # Compact (remove empty elements)
agent-browser snapshot -d 3 # Limit depth to 3 levels
agent-browser snapshot -s "#main" # Scope to CSS selector
agent-browser snapshot -i -c -d 5 # Combine options| Option | Description |
|---|---|
-i, --interactive | Only interactive elements (buttons, links, inputs) |
-c, --compact | Remove empty structural elements |
-d, --depth | Limit tree depth |
-s, --selector | Scope to CSS selector |
Output format
agent-browser snapshot
# Output:
# - heading "Example Domain" [ref=e1] [level=1]
# - button "Submit" [ref=e2]
# - textbox "Email" [ref=e3]
# - link "Learn more" [ref=e4]JSON output
Use --json for machine-readable output:
agent-browser snapshot --json
# {"success":true,"data":{"snapshot":"...","refs":{"e1":{"role":"heading","name":"Title"},...}}}Best practices
- Use
-ito reduce output to actionable elements - Use
--jsonfor structured parsing - Re-snapshot after page changes to get updated refs
- Scope with
-sfor specific page sections