Skip to content

[📋 ADR]: Accessibility tree snapshots (#18205) #18345

Open
0 of 3 issues completed
Open

Description

@AutomatedTester

Decision record

docs/decisions/18205-accessibility-tree-snapshot.md (#18205), approved by @titusfortner and @diemol on 17 Nov 2026. The record is at revision 9eeaf92: Classic and BiDi both supported, the driver's snapshot rooted at the current browsing context, methods on a role interface where the binding has them. This link moves to trunk when #18205 merges.

Binding implementation

Each sub-issue holds the plan for that binding, written for that language. They are the plans we will implement if people are happy with them, so please comment on the sub-issue before a PR goes up. Nothing has been started for Java, Ruby or .NET.

Already shared by every binding

Reference behaviour (from the Python and JavaScript implementations)

Every binding should match this. The Python tests in py/test/selenium/webdriver/common/accessibility_snapshot_tests.py are the checklist.

  1. Which path. If the session has a webSocketUrl, run the atom with script.callFunction in the selenium sandbox of the current browsing context (resultOwnership: none, maxDomDepth: 0). Use raw protocol calls, not public BiDi wrappers that are deprecated or on their way out. Otherwise, run the atom through Execute Script. If the current context id cannot be found (Python uses the window reference from return window), fall back to Execute Script.
  2. Root. The driver's snapshot is of the current browsing context, which is the top-level document or the frame the driver switched into. Its root has role document and is named from the title. An element's snapshot always has that element as its root. A hidden element gives a root with no children.
  3. Frames. Each iframe node gets its frame's tree as its one child. Over BiDi this uses the returned window references. Over Classic it switches into the iframe element, takes the snapshot, then calls parent_frame. A frame that cannot be reached (no such frame, mid-navigation, stale) stays an iframe node with no children and is logged at debug level. The driver's current browsing context is always restored.
  4. Element snapshot over BiDi. The element can be in any frame of the window, so try each context of browsingContext.getTree (top first, then depth-first) until the atom accepts the shared id. Over Classic, the element must be in the current browsing context.
  5. Errors. A stale or detached root raises the binding's existing stale element error. Any other failure is a normal WebDriver error.
  6. Node type. It is an immutable value: role, name, description, optional value, optional url, states, optional element, children. Element references are the binding's normal element type and work for later commands (after switching frames, for nodes in a child frame).
  7. Text form. toText / to_text / ToText follows ADR §1. It must produce exactly the corpus .txt files, and it is unit-tested without a browser.
  8. interestingOnly. Default true. false keeps unnamed generic/none/presentation nodes. All five bindings keep this option even though the record does not mention it.
  9. Nothing is deprecated. This only adds API and replaces nothing, so under the deprecation rule agreed in [docs] ADR: windows are objects, reached through driver.windows #17681 there is nothing to deprecate.

Notes

  • New API returns AccessibilityNode objects. Text is only produced by rendering a node, never returned as a bare string.
  • Open across bindings: should the atom drop SVG <title>/<desc> for all engines, so that we no longer need the 007 WebKit divergence? That would change the shared corpus.
  • .NET has no maintainer for this. The plan is detailed enough for a contributor to pick up.

Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions