Overview
Methods
snapshot(options?)
Capture a snapshot of the accessibility tree.boolean
default:"true"
Filter out nodes that are not interesting for most accessibility tests. When false, returns the full tree including nodes that are typically ignored by screen readers.
ElementHandle
Root element to capture the snapshot from. If not specified, captures the entire page.
Promise<AccessibilityNode | null>
Returns a JSON representation of the accessibility tree. Returns null if the root element is not accessible.
AccessibilityNode Structure
Examples
Basic Snapshot
Snapshot Specific Element
Full Tree Snapshot
Verify Button Accessibility
Check Form Accessibility
Navigate Accessibility Tree
Verify ARIA Attributes
Check Heading Hierarchy
Use Cases
Automated Accessibility Testing
Compare Before and After
Best Practices
Combine with Role Locators
Use accessibility snapshots together with role-based locators:Focus on Interesting Nodes
KeepinterestingOnly: true (default) for most tests to avoid noise from decorative elements.
Use for Screen Reader Testing
Snapshots show what screen readers will announce:Limitations
- Primarily supported in Chromium-based browsers
- May not capture all platform-specific accessibility information
- Does not replace manual accessibility testing with real assistive technologies
- The tree structure is a snapshot at a point in time
Browser Compatibility
Related
- Role Selectors - Select elements by ARIA role
- ARIA Snapshot - Alternative snapshot format
- Accessibility Testing - Comprehensive testing guide
