[rb] Implement accessibility snapshots (ADR 18205)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, ruby
調査の方向性
Start with ADR 18205 and the reference behavior in issues #18307 and #18308, then inspect the Ruby bridge, snapshotter, atom build target, and RBS files named here. Implement the Ruby API and cover it with the listed unit and integration specs in Classic and BiDi runs; done means Steep and the specified snapshot cases pass. This is a broad feature spanning bridges, generated protocol calls, frames, and browser tests.
索引モデルが issue の本文から書いたものです。
説明
Part of #18345, the ADR 18205 tracker. This is the Ruby plan we will implement if people are happy with it. Please comment here before the PR goes up.
Python (#18307) and JavaScript (#18308) set the reference behaviour, listed in the tracker. This issue only covers how Ruby does it.
Public API
Ruby has no role interfaces, so, as the record says, the method goes on Driver and Element directly, next to #screenshot:
tree = driver.accessibility_snapshot
puts tree.to_text
form = driver.find_element(id: 'login').accessibility_snapshot(interesting_only: false)
- Signature:
accessibility_snapshot(interesting_only: true) -> AccessibilityNode. It takes a keyword argument rather than an options object, which matchesprint_page(**options)and the rest of the Ruby API. - Raises
Error::StaleElementReferenceErrorfor a stale or detached root.
Selenium::WebDriver::AccessibilityNode
This is an immutable value. It uses Data.define (the gem needs Ruby >= 3.3), with keyword construction and frozen collections:
AccessibilityNode = Data.define(:role, :name, :description, :value, :url, :states, :element, :children) do
def each_node(&) = ... # self, then descendants, depth-first; an Enumerator without a block
def to_text = ... # ADR §1 text form
def checked? = ... # and pressed?, expanded?, selected?, disabled?, focused?
def level = states[:level]
alias_method :to_s, :to_text
end
role,nameanddescriptionareString.valueandurlareStringornil.elementis anElementornil.childrenis a frozenArray.statesis a frozenHashwith symbol keys, as the rest of the Ruby API uses:{checked: :mixed, level: 2, disabled: true}."mixed"becomes:mixed, sonode.states[:checked] == :mixedreads naturally. Unknown future keys come through as symbols too, and callers ignore them, as the record's compatibility rule says.- The predicates are Ruby extras on top of
states. Each one istrueonly when the state istrue, sochecked?isfalsefor:mixed, and callers who need the tri-state readstates[:checked].each_nodereturns anEnumeratorwhen called without a block, so the tree can be searched with the wholeEnumerableAPI. It is an enumerator rather thaninclude Enumerableon the node, becauseEnumerable#to_hwould hideData#to_h:
driver.accessibility_snapshot.each_node
.find { |n| n.role == 'button' && n.name == 'Submit' }
&.element&.click
headings = driver.accessibility_snapshot.each_node.select { _1.role == 'heading' }.map { [_1.level, _1.name] }
These extras are additive under the record's compatibility rule. They can be dropped if we want strict parity with Python and JavaScript.
Internals
The bridges choose the path, so there is no if bidi? in the driver:
Remote::Bridge#accessibility_snapshot(root, interesting_only:)is the Classic path. It callsexecute_scriptwith the atom source. For frames it callsswitch_to_frame(iframe_element), thenswitch_to_parent_framein anensure.Remote::BiDiBridge#accessibility_snapshotis the BiDi path. It uses the generatedBiDi::Protocol::Script#call_functionandBiDi::Protocol::BrowsingContext#get_treeover the bridge's existingconnection(asbrowsing_context/web_extensionalready do). It does not usedriver.bidi/send_cmd, which ADR 17670 is moving away from. If the current browsing context id cannot be found, it falls back tosuper.AccessibilitySnapshotter(@api private) holds the shared code: building nodes from the wire (with a block for frame children,AccessibilityNode.from_wire(data, elements) { |frame| ... }), mapping element indexes toElement, and the stitching and unreachable-frame rules. Frames that cannot be reached logWebDriver.logger.debug(..., id: :accessibility_snapshot)and become childlessiframenodes.- Atom: a target in
rb/lib/selenium/webdriver/atoms/BUILD.bazelcopies//javascript/atoms/fragments:accessibility-snapshot-wire-typescript.jsinto the gem, read once withAtoms#read_atom. - RBS:
rb/sig/lib/selenium/webdriver/common/accessibility_node.rbs, plus additions todriver.rbs,element.rbs,remote/bridge.rbsandremote/bidi_bridge.rbs. Steep must pass. - YARD on the public methods describes the output as computed and not the browser's own tree.
Tests
rb/spec/unit/selenium/webdriver/common/accessibility_node_spec.rb(no browser): checksto_textagainst every corpus.json/.txtpair, plus escaping, state order, symbol keys, the predicates andeach_nodeorder.rb/spec/integration/selenium/webdriver/accessibility_snapshot_spec.rb: iterates overindex.json, pruned and unpruned, preferring.webkitexpectations on Safari. It runs in both Classic andWEBDRIVER_BIDIruns, so both bridges are covered. It also ports the other cases from the Python suite (switched frame root, context restored, frames stitched, subtree in a frame, stale and detached roots, usable element references, snapshot is a copy). Any browser exceptions usepending_if/skip_ifwith areason:.
Not changing
Nothing is deprecated, because this replaces no existing call. Using driver.bidi directly is no longer needed for this feature.
Generated by Claude Code
- 主要言語
- Java
- スター
- 34.6k
- フォーク
- 8.7k
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 107
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SeleniumHQ/selenium のほかの issue
-
C-py I-defect
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
SeleniumHQ/selenium#18438 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
SeleniumHQ/selenium#18323 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
B-build C-py I-enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
SeleniumHQ/selenium#18435 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[🐛 Bug]: Bindings change the user's options when Selenium Manager supplies a browser対応中かも @Liz-Lian が 2 日前に担当しました。 オープンC-dotnet C-java C-nodejs C-py C-rb I-defect
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
SeleniumHQ/selenium#18428 ·
メンテナーはふだん 1 日以内に返信
-
[🐛 Bug]: [rust] Selenium Manager can return a browser from the cache before it finishes copying対応中かも @Liz-Lian が 2 日前に担当しました。 オープンC-rust I-defect
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
SeleniumHQ/selenium#18427 ·
メンテナーはふだん 1 日以内に返信
SeleniumHQ/selenium の issue をすべて見る
似ている issue
-
area-integrations
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
? - Needs Triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NVIDIA/cudf-spark-jni#5598 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
oracle/graalvm-reachability-metadata#12264 ·
メンテナーはふだん 1 日以内に返信
-
[source-facebook-pages] post stream never returns attachments.media_type対応中かも @v-k-data が今日担当しました。 オープンarea/connectors needs-triage type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
[BUG] AppSync: GetIntrospectionSchema wraps the schema in JSON instead of returning the raw SDL bodyオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
floci-io/floci#10107 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信