Repository navigation
Description
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
- Java — [java] Implement accessibility snapshots (ADR 18205) #18346 (plan)
- Python — [py] Snapshot accessibility in Classic sessions too #18307 (Classic path, raw BiDi, no deprecated
driver.scriptcalls), on top of [js][py][rb][java][dotnet] add the accessibility snapshot atom and the binding methods #18232; Safari follow-up [py] Fix accessibility snapshot tests on Safari #18317 - Ruby — [rb] Implement accessibility snapshots (ADR 18205) #18347 (plan)
- .NET — [dotnet] Implement accessibility snapshots (ADR 18205) #18348 (plan; no owner yet)
- JavaScript — [js] Snapshot accessibility in Classic sessions too #18308, on top of [js][py][rb][java][dotnet] add the accessibility snapshot atom and the binding methods #18232
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
- The atom:
//javascript/atoms/fragments:accessibility-snapshot-wire-typescript.js([js][py][rb][java][dotnet] add the accessibility snapshot atom and the binding methods #18232). It computes the tree for one document and returns the tree as a JSON string next to the element references and child frame windows. Bindings do not compute roles, names or pruning themselves. - The corpus:
common/src/web/accessibility/. It has the expected pruned and unpruned JSON and text for each page, plus engine-specific.webkitfiles where WebKit differs. Every binding runs every page in each browser it tests. - The earlier Java, Ruby and .NET adoptions from [js][py][rb][java][dotnet] add the accessibility snapshot atom and the binding methods #18232 were removed in [java][rb][dotnet] Remove the accessibility snapshot client implementations #18291. They were BiDi-only and put the methods on
WebDriver/WebElement, so they predate 9eeaf92. The new plans start from the current record and reuse those files only where they still fit.
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.
- Which path. If the session has a
webSocketUrl, run the atom withscript.callFunctionin theseleniumsandbox 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 fromreturn window), fall back to Execute Script. - 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
documentand 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. - Frames. Each
iframenode 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 callsparent_frame. A frame that cannot be reached (no such frame, mid-navigation, stale) stays aniframenode with no children and is logged at debug level. The driver's current browsing context is always restored. - 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. - Errors. A stale or detached root raises the binding's existing stale element error. Any other failure is a normal WebDriver error.
- Node type. It is an immutable value:
role,name,description, optionalvalue, optionalurl,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). - Text form.
toText/to_text/ToTextfollows ADR §1. It must produce exactly the corpus.txtfiles, and it is unit-tested without a browser. interestingOnly. Defaulttrue.falsekeeps unnamedgeneric/none/presentationnodes. All five bindings keep this option even though the record does not mention it.- 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
AccessibilityNodeobjects. 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 the007WebKit 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
Activity