Skip to content

[docs] ADR: accessibility tree snapshots ship as a script-based module before a BiDi command exists - #18205

Open
AutomatedTester wants to merge 12 commits into
trunkfrom
adr-accessibility-snapshot
Open

AutomatedTester wants to merge 12 commits into
trunkfrom
adr-accessibility-snapshot

Conversation

@AutomatedTester

@AutomatedTester AutomatedTester commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

📄 The decision, its rationale, considered options, and consequences are in the record file
this PR adds; read it there. The sections below are proposal notes and review logistics.

🔗 Related

📝 Proposal notes

  • The public API, data model, element references and cross-binding adoption are in one record because they ship together: the schema is the compatibility commitment the API returns, and the shared test corpus is how the bindings are held to it.
  • WebDriver Classic sessions are deliberately out of scope; they raise rather than return a partial snapshot.
  • Deferred to the implementing PRs: the exact pruning algorithm (pinned by the shared test corpus rather than the record), the divergence document, and whether an option to omit element references is needed.
  • Follow-on: contributing the schema and divergence list to Accessibility module in WebDriver BiDi? w3c/webdriver-bidi#443.

🗣 Discussion

Revised after the first review (public API, schema, binding adoption, Classic scope):

  • Is a driver method plus an element method the right split, or would a single driver method with an optional root be preferable?
  • Is the compatibility rule (additive fields and states keys are non-breaking; accuracy fixes to names, roles and pruning can ship in any release) acceptable?
  • Is leaving Classic out acceptable, given it would need frame switching and has no sandbox?
  • Owning our own accname/role implementation versus a dependency on dom-accessibility-api.

Discussed at the TLC meetings below; see the minutes for the full discussion and attribution.

  • 2026-11-12: support Classic through execute script, with a pinned script possible later; a snapshot taken inside a frame covers that frame.
  • 2026-11-19: use the same method name in every binding ("accessibility snapshot"); keep binding implementation details such as casting out of the record.

📌 Tracking

Tracking issue: (linked on acceptance)


🤖 AI assistance

  • AI assisted
    • Tool(s): Claude Code
    • What was generated: drafting of the ADR text and the search for prior work (Selenium, WebdriverIO and w3c/webdriver-bidi issues and PRs)

🤖 Generated with Claude Code

@selenium-ci

Copy link
Copy Markdown
Member

/agentic_describe

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Document the proposed BiDi accessibility snapshot strategy

📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Proposes a script-computed accessibility snapshot while WebDriver BiDi lacks a native tree
 command.
• Defines a shared atom, structured tree output, and per-binding iframe stitching for future
 implementation.
• Records fidelity and maintenance tradeoffs, with findings intended to inform BiDi standardization.
Diagram

graph TD
  A["Selenium bindings"] --> B["BiDi scripts"] --> C["Sandbox atom"] --> D["JSON subtrees"] --> E["Iframe stitching"] --> F["Snapshot output"]
  E --> G["Text serializers"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use dom-accessibility-api for name and role computation
  • ➕ Reduces the largest proposed implementation and maintenance burden.
  • ➖ Adds a runtime dependency across Selenium releases.
  • ➖ Reduces independence when comparing results with WebdriverIO.
2. Wait for a native BiDi tree command
  • ➕ Could provide browser-native fidelity without a maintained script implementation.
  • ➖ Leaves users without snapshots while tree semantics remain unresolved.

Recommendation: The proposed script-first, structured-output approach is a reasonable bridge to a native BiDi command. Before accepting the decision, explicitly confirm that owning and maintaining accessible-name and role computation is preferable to the dependency, and keep the promised divergence evidence central to the follow-up work.

Files changed (1) +143 / -0

Documentation (1) +143 / -0
18205-accessibility-tree-snapshot.mdPropose a script-based accessibility snapshot ADR +143/-0

Propose a script-based accessibility snapshot ADR

• Adds a proposed decision to deliver computed accessibility snapshots through a shared Selenium atom and standard BiDi, with structured output and client-side iframe stitching. Documents expected fidelity gaps, cross-binding maintenance, alternatives, and how implementation evidence would feed the existing BiDi accessibility proposal. It does not implement the module or binding APIs.

docs/decisions/18205-accessibility-tree-snapshot.md

@qodo-code-review

qodo-code-review Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 9eeaf92 ⏭️ Skipped

Results up to commit 7647a64 ⏭️ Skipped


No changes from previous review

Results up to commit 577e841 ⏭️ Skipped


No changes from previous review

Results up to commit 61997b1 ⏭️ Skipped


No changes from previous review

Results up to commit 367e06e ⏭️ Skipped


No changes from previous review

Results up to commit 95d94c6 ⏭️ Skipped


No changes from previous review

Results up to commit e89cbfa ⏭️ Skipped


No changes from previous review

Results up to commit 02dd33d ⏭️ Skipped


No changes from previous review

Results up to commit 2df928c ⏭️ Skipped


No changes from previous review

Results up to commit cfa486e ⏭️ Skipped


No changes from previous review

Results up to commit c26ee1b ⏭️ Skipped


No changes from previous review

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 577e841

@diemol diemol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like the idea overall because this is a good feature to have and to offer our end users.

But I don't see what the public API will look like. What are the methods we're going to offer, and what is the contract?

We're talking about a schema which seems to be deferred to the implementation PR, but the ADR says that changes are breaking, so it's hard to keep that promise if we don't declare the schema already.

We should also think about how each binding will adopt this. In that way, we can avoid each binding going its own way.

This is all about BiDi, but are sessions with Webdriver Classic in scope as well? If not, we should write that explicitely.

By the way, this seems to be using the wrong PR template. It's using the template for pull requests and not the one for HDRs, so can you please correct that?

… and Classic scope

Addresses review: the record now fixes method names per binding, the
AccessibilityNode schema and a compatibility rule, a shared test corpus as
the cross-binding contract, and states that WebDriver Classic sessions raise.
Sections reordered to match the ADR template.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 61997b1

Root node, iframe token, hidden-root behaviour, the full text-form grammar,
the states table as implemented, the corpus location and schema, shadow DOM
limits, and a first wire-size data point.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 367e06e

@diemol

diemol commented Oct 29, 2026

Copy link
Copy Markdown
Member

A few more things:

  1. Element references from child frames. The record says a snapshot node "can be clicked, typed into, or used as the root of a further snapshot without a second lookup." That works for elements in the current browsing context. But the bindings still send Classic commands for element actions (click, send keys, etc.), and those only look in the frame the driver is switched to. An element from a child frame, especially a cross-origin one, would fail with "no such element" unless the user switches to that frame first. Can we either say this in the contract and Consequences, or say how the bindings will handle it (for example, by sending BiDi input actions for these elements)?
  2. Length. docs/decisions/README.md asks for records of about a page. This one is several pages. The Context section (WG history, WPT RFC, charter timing) and some of the Considered options could be shorter, or link to the issues instead. The API contract, data model, and compatibility rule are the parts reviewers and implementers need.
  3. Text rendering. Each binding writes its own toText(), checked against a reference renderer. Could the atom also produce the text, from the stitched tree? Then there's one implementation instead of five that can drift apart. This isn't a blocker; I just want to know if it was considered.

@AutomatedTester

Copy link
Copy Markdown
Member Author

@diemol thanks, all three are fair. Taking them in order:

1. Element references from child frames. You're right, and the record overstates it. Classic element commands resolve a reference against the current browsing context, so a node from a child frame (cross-origin or not) gives "no such element" until the driver is switched into that frame. The same applies the other way: a whole-page snapshot is rooted at the top-level context, so if the driver is switched into a frame, top-level nodes fail too. I'll make the contract say this directly: a reference is usable with Classic commands while the driver's current frame is that node's document, and with BiDi commands that take a SharedReference from anywhere. The iframe nodes on the path to a node carry the elements needed to switch there, so the user always has what they need.

I don't want the bindings to switch frames implicitly, for the same reason the record rejects Classic: it changes the session's current browsing context as a side effect. Routing click and send keys for these elements through BiDi input.performActions would remove the limitation, but that changes how element actions are dispatched generally, so it should be its own record rather than something this one decides. I'll put it in Consequences as the known gap and the likely follow-up.

2. Length. Agreed. I'll cut Context down to the problem, the state of #443 with links (dropping the minutes, WPT RFC and charter detail), and the precedent paragraph; shrink each considered option to a line or two; and tighten Consequences. The API contract, data model and compatibility rule stay as they are. With the two tables it won't get to a single page, but it should get close.

3. Text rendering in the atom. It was considered, but the record doesn't say so, and it should. The atom runs once per document and never sees the stitched tree; that happens in the binding. To render in the atom, the binding would send the stitched tree back into the page and call the renderer there. That works, but it costs an extra round trip carrying the whole tree (about 366 KB for 5,000 nodes), and it means a snapshot can't be rendered without a live session, so a saved or deserialized AccessibilityNode couldn't produce its text. The renderer is a small, fixed line grammar, and every binding's output is checked against the corpus's expected text, so drift shows up as a failing test rather than in users' hands. I'd keep it per binding and add this as a considered option with that reasoning. If you'd rather have one implementation and accept the round trip, I'm fine with switching.

I'll push these changes to this PR.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 95d94c6

… atom injection, wire entry, text escaping

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit e89cbfa

@diemol diemol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. My earlier points are covered: the API, schema, Classic scope, frame references and the text rendering choice. LGTM once the two small comments above are handled.

A node of role link carries the resolved absolute URL of its element's
href as an optional url field, as CDP's accessibility tree exposes it;
a link without href has none. The text form does not render it, as it
does not render the description. Raised in review of the implementing
PR, where the href was reachable only through the element reference.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 02dd33d

Both snapshot methods take an optional interestingOnly parameter,
true by default, after Puppeteer's accessibility.snapshot(): with
false the pruning rule is turned off and every rendered element
produces a node, with generic, none and presentation reported as the
roles they are. Hidden-ness, names, states and references are the
same in both modes, and the corpus records both forms of every page.
Requested in review of the implementing PR by users of CDP's full
tree; always pruning and never pruning are recorded as the rejected
options.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 2df928c

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit cfa486e

…delivery to the implementing PRs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit c26ee1b

@titusfortner titusfortner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This shouldn't be limited to BiDi.
  2. The snapshot method should respect the current driver context, so if it is switched into a frame, the results should be limited to just the frame's context.
  3. I don't think the method belongs in driver/element interface, it should have its own interface (like TakeScreenshot / JavaScriptExecutor)
  4. I think this ADR is over-specifying a number of implementation details that don't matter for the decision we are making. So there are a lot of little things I'd quibble with in the decisions that I don't think are correct, but I also don't think they matter? For example:
    • I don't think we need to include anything about the parameters or potential future toggles we may add for additional arguments; as long as we have the name and the output set we can add things later if/when we decide to.
  • Section 4’s export paths, packaging forms, corpus location and per-browser test matrix are implementation details that don't matter to the decision.
  • Section 5’s @wdio/snapshot comparison and spec-contribution plan are intentions with external dependencies, not decisions.

I think we may want to tweak our README/Template a bit to keep these more focused.

…le interface, drop implementation detail

Addresses review from Titus: the snapshot is no longer BiDi-only, the
driver's snapshot is rooted at the current browsing context, the methods
live on their own interface like TakesScreenshot, and parameters,
packaging, corpus layout and spec plans are left to implementing PRs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@selenium-ci

Copy link
Copy Markdown
Member

/agentic_review

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 9eeaf92

@titusfortner titusfortner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. Everything looks good to me now. I merged #18291 so we can do a release

- The driver's snapshot is rooted at the driver's current browsing context: the top-level
document, or the frame the driver has switched into. Its root node has role `document`, is named
from that document's title, and references its document element.
- An element's snapshot always produces a root node, even when the pruning rule below would drop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if in the root visibility: hidden and child in root has visibility: visible , it still retuns the child.
and buildtree in atom only skips children when the complete subtree is hidden with aria-hidden, display: none

### 3. Element references

Every node backed by an element carries it as the binding's normal element type, so a snapshot
node can be acted on without a second lookup. Element commands resolve references against the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may work differently in clasic and bidi, example in frame , bidi returns all frames and classic returns the frame we are currently in. also i see in py code comments WebDriver Classic session the element must belong to the driver's current browsing context and behavior is diff in bidi

sorry if i am wring here


### 1. Public API

The snapshot methods live on their own interface, as screenshots do with `TakesScreenshot`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my understanding, in Java, screenshots work directly on an element, but a driver needs a cast first because WebElement extends TakesScreenshot and WebDriver does not.

If snapshots copies this, the method ends up on WebElement, but the ADR rejects putting the method on WebElement

If snapshots do not copy this, every element needs a cast before taking a snapshot so confused here

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants