browser_snapshot
Capture a snapshot of the page's interactive elements with stable refs, so automation can reliably click, fill, and inspect without fragile CSS selectors.
Instructions
Return the accessibility tree of the current page with refs attached to interactive elements (buttons, links, textboxes, checkboxes, etc.). Use this INSTEAD of guessing CSS selectors from a screenshot — selectors break on class-name churn, refs don't.
Returns { url, snapshot: [...tree], refs: [{ref, selector, role, name, testId}, ...] }.
Each ref like "e9" maps internally to a stable selector. Pass refs to browser_act: browser_act({ commands: [ { action: "fill", ref: "e42", value: "user@example.com" }, { action: "click", ref: "e9" } ]})
Every node includes testId when the element has data-testid, data-test, or data-qa — use these as additional stability anchors. Refs are invalidated automatically on navigation — re-snapshot after any browser_navigate or URL change.
Use compact: true to drop pure layout wrappers (divs/spans with no role, no testId) and return a flatter tree focused on interactive content. Recommended for noisy apps with deeply-nested div soup.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compact | No | Drop non-semantic wrapper elements (divs/spans without role or testId). Flattens noisy trees. | |
| max_depth | No | Max tree depth (default: 10) |