[dotnet] Implement accessibility snapshots (ADR 18205)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 50/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp, javascript, json
調査の方向性
Start with the .NET WebDriver API and implementation around ITakesScreenshot and INavigation.BackAsync(), then read ADR 18205 and the Python and JavaScript issues for reference behavior. The issue names the atom resource, build and project files, and test files to add. Done means the async snapshot API, classic path, frame handling, wrapper forwarding, and listed tests are implemented; the BiDi sandbox path is deferred until the driver owns an internal connection.
索引モデルが issue の本文から書いたものです。
説明
Part of #18345, the ADR 18205 tracker. This is the .NET plan we will implement if people are happy with it. Please comment here before the PR goes up.
No owner yet. Nobody currently maintains this in .NET. The plan is detailed enough for a contributor to pick up. Please say so here if you take it.
Python (#18307) and JavaScript (#18308) set the reference behaviour, listed in the tracker. This issue only covers how .NET does it.
Public API (OpenQA.Selenium)
This is a role interface, following ITakesScreenshot. It is implemented by WebDriver and WebElement, so ChromeDriver, FirefoxDriver, RemoteWebDriver and the others all get it, and nothing changes on IWebDriver/IWebElement. Following the record, the API is async only, in the same pattern as INavigation.BackAsync() and the rest of the async migration:
public interface ITakesAccessibilitySnapshot
{
/// <exception cref="StaleElementReferenceException">When called on an element that is no longer attached.</exception>
Task<AccessibilityNode> GetAccessibilitySnapshotAsync(
AccessibilitySnapshotOptions? options = null,
CancellationToken cancellationToken = default);
}
public sealed record AccessibilitySnapshotOptions
{
/// <summary>Defaults to <see langword="true"/>: unnamed generic and presentational elements are pruned.</summary>
public bool InterestingOnly { get; init; } = true;
}
The options type is a record with init properties, as the BiDi *Options types already are. Callers write new() { InterestingOnly = false }, and later options can be added without breaking anyone.
public sealed class AccessibilityNode
{
public string Role { get; } // "text" for text leaves, "iframe" for frames
public string Name { get; } // "" when none
public string Description { get; } // "" when none
public string? Value { get; } // textbox, searchbox, combobox, range
public string? Url { get; } // links with an href
public IReadOnlyDictionary<string, object> States { get; } // bool, int, or the string "mixed"
public IWebElement? Element { get; } // null for text leaves and generated content
public IReadOnlyList<AccessibilityNode> Children { get; } // empty for leaves
public IEnumerable<AccessibilityNode> DescendantsAndSelf(); // depth-first, for LINQ
public string ToText(); // ADR §1 text form
public override string ToString(); // same as ToText()
}
AccessibilityNodeis asealed class, not arecord. Record value equality over an element reference and a child list would compare by reference and give misleading results. Its collections are read-only copies, so a snapshot is a value that does not change.- Nullable reference types mark the optional fields, as the rest of the assembly does.
DescendantsAndSelf()is a .NET extra, named afterXElement.DescendantsAndSelf(). It is additive under the record's compatibility rule and can be dropped if we want strict parity.
var snapshots = (ITakesAccessibilitySnapshot)driver;
AccessibilityNode tree = await snapshots.GetAccessibilitySnapshotAsync();
Console.WriteLine(tree.ToText());
tree.DescendantsAndSelf()
.FirstOrDefault(n => n.Role == "button" && n.Name == "Submit")
?.Element?.Click();
var login = (ITakesAccessibilitySnapshot)driver.FindElement(By.Id("login"));
var full = await login.GetAccessibilitySnapshotAsync(new() { InterestingOnly = false });
Internals (internal sealed class AccessibilitySnapshotter, one per WebDriver, created lazily)
- Classic path, used in every session at first. It runs the atom with Execute Script through the existing
ExecuteAsync, withConfigureAwait(false)everywhere and theCancellationTokenpassed through. Results go through the driver's normal element factory, so references are ordinaryWebElements. Frames are reached by switching into each iframe element, with the switch back to the parent frame in afinally. The record allows this: script execution is available in BiDi sessions too, and the output is the same. - BiDi sandbox path, phase 2. Today
WebDriverowns no BiDi connection.AsBiDiAsync()opens a new WebSocket on each call and is the public surface ADR 17670 wants to make internal. Opening a socket for each snapshot would be expensive. Holding one inWebDriveris the driver-owned connection that #18291 removed, and that belongs with the .NET ADR 17670 work. So the sandbox path (script.callFunctionin theseleniumsandbox,browsingContext.getTreefor element roots in child frames) lands once the driver owns an internal connection. It sits behind the same public API, so users see no change. - Frames that cannot be reached are logged with
_logger.Debug(...)(OpenQA.Selenium.Internal.Logging) and become childlessiframenodes. A stale root throwsStaleElementReferenceException. - Atom: an embedded resource built from
//javascript/atoms/fragments:accessibility-snapshot-wire-typescript.js(dotnet/src/webdriver/BUILD.bazeland the csproj), loaded once throughResourceUtilities. - Wire parsing uses
System.Text.Json, which is already a dependency, so it works onnet462,netstandard2.0andnet8.0without new packages.
Support package
EventFiringWebDriver and its EventFiringWebElement implement ITakesAccessibilitySnapshot by forwarding to the wrapped object when it implements the interface, and throw NotSupportedException when it does not. This matches how they handle ITakesScreenshot. Element references in the returned tree are wrapped too, so events fire for actions on them.
Tests
dotnet/test/unit/webdriver/AccessibilityNodeTests.cs(no browser): checksToText()against every corpus.json/.txtpair, plus escaping and state order.dotnet/test/webdriver/AccessibilitySnapshotTests.cs(NUnit,[TestCaseSource]overindex.json): pruned and unpruned per page, preferring.webkitfiles on Safari. 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, cancellation honoured).dotnet/test/support/: a forwarding test for theEventFiring*wrappers.
Not changing
Nothing is deprecated, because this replaces no existing call. There are no sync overloads: the record specifies GetAccessibilitySnapshotAsync, and new .NET API is async.
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 日以内に返信