AxeRunContext クラス

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

axe Watcher を使ってアクセシビリティテストのためのコンテキストを、DOM要素の含むまたは除外によって構成します

Not for use with personal data

この AxeRunContext クラスを使用すると、分析中にどのDOM要素を含むかまたは除外するかを指定することによって、アクセシビリティテストの範囲を定義できます。これにより、ページの特定の部分に分析を集中させたり、関連性のない部分を除外したりして、テストプロセスをより細かく制御できます。

要素を含む場合、その要素のみが分析されます。要素を除外する場合、それらの要素は分析から除外されますが、ページ上の他のすべての要素は分析されます。

コンストラクタ

AxeRunContext()

新しいインスタンスを作成し、 AxeRunContext 空の包含リストと除外リストを持つ。

AxeRunContext context = new AxeRunContext();

メソッド

setInclude(List<String> include)

アクセシビリティ分析に含める要素を指定します。含まれる要素を設定すると、 その要素のみが分析されます

パラメータ:

  • include - 分析に含めるCSSセレクタのリスト

戻り値:

  • AxeRunContext - メソッドチェーンのための現在のインスタンス

例:

AxeRunContext context = new AxeRunContext();
context.setInclude(Arrays.asList("#main-content", ".important-section"));

setExclude(List<String> exclude)

アクセシビリティ分析から除外する要素を指定します。

パラメータ:

  • exclude - 分析から除外するCSSセレクタのリスト

戻り値:

  • AxeRunContext - メソッドチェーンのための現在のインスタンス

例:

AxeRunContext context = new AxeRunContext();
context.setExclude(Arrays.asList(".ad-section", "#header-navigation"));

getInclude()

分析に含まれているCSSセレクタのリストを取得します。

戻り値:

  • List<String> - 含まれているCSSセレクタのリスト

例:

AxeRunContext context = new AxeRunContext();
context.setInclude(Arrays.asList("#main-content"));
List<String> includeSelectors = context.getInclude();

getExclude()

分析から除外されているCSSセレクタのリストを取得します。

戻り値:

  • List<String> - 除外されているCSSセレクタのリスト

例:

AxeRunContext context = new AxeRunContext();
context.setExclude(Arrays.asList(".ad-section"));
List<String> excludeSelectors = context.getExclude();

toJson()

インスタンスをJSON文字列にシリアライズします。 AxeRunContext インスタンスをJSON文字列に変換します。

戻り値:

  • String - コンテキストのJSON文字列表現

例:

AxeRunContext context = new AxeRunContext()
    .setInclude(Arrays.asList("#main-content"))
    .setExclude(Arrays.asList(".ad-section"));
String json = context.toJson();
// Returns: {"include":["#main-content"],"exclude":[".ad-section"]}

関連項目