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
OptionDescription
-i, --interactiveOnly interactive elements (buttons, links, inputs)
-c, --compactRemove empty structural elements
-d, --depthLimit tree depth
-s, --selectorScope 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

  1. Use -i to reduce output to actionable elements
  2. Use --json for structured parsing
  3. Re-snapshot after page changes to get updated refs
  4. Scope with -s for specific page sections