import { CodeBlock } from "@/components/code-block"; export default function Snapshots() { return (

Snapshots

The snapshot command returns a compact accessibility tree with refs for element interaction.

Options

Filter output to reduce size:

Option Description
-i, --interactive Only interactive elements (buttons, links, inputs)
-C, --cursor Include cursor-interactive elements (cursor:pointer, onclick, tabindex)
-c, --compact Remove empty structural elements
-d, --depth Limit tree depth
-s, --selector Scope to CSS selector

Cursor-interactive elements

Many modern web apps use custom clickable elements (divs, spans) instead of standard buttons or links. The -C flag detects these by looking for:

  • cursor: pointer CSS style
  • onclick attribute or handler
  • tabindex attribute (keyboard focusable)

Output format

The default text output is compact and AI-friendly:

Using refs

Refs from the snapshot map directly to commands:

Ref lifecycle

Refs are invalidated when the page changes. Always re-snapshot after navigation or DOM updates:

Best practices

  1. Use -i to reduce output to actionable elements
  2. Re-snapshot after page changes to get updated refs
  3. Scope with -s for specific page sections
  4. Use -d to limit depth on complex pages

JSON output

For programmatic parsing in scripts:

Note: JSON uses more tokens than text output. The default text format is preferred for AI agents.

); }