Skip to main content
The Accessibility class provides methods to capture snapshots of the accessibility tree. This is useful for automated accessibility testing and understanding how assistive technologies perceive your page.

Overview

Note: The Accessibility API is primarily available in Chromium-based browsers. It provides access to the browser’s accessibility tree, which is what screen readers and other assistive technologies use.

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.
Returns: 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

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

Keep interestingOnly: 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