AxeRunOptionsクラス

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

Javaでaxe Watcherを使用したアクセシビリティテストの高度な実行オプションを設定

Not for use with personal data

この AxeRunOptions クラスは、axe-coreがアクセシビリティテストを実行する際の設定オプションを提供します。このクラスを使用することで、特定のルールの有効化や無効化、実行するルールの制限、およびアクセシビリティ違反の祖先情報などの分析詳細を設定することができます。

これらのオプションは、実行時にaxe-coreに渡され、アクセシビリティ解析エンジンの動作をカスタマイズします。

コンストラクタ

AxeRunOptions()

新しいインスタンスを作成します。 AxeRunOptions デフォルト設定で。デフォルトでは、 ancestry プロパティは falseに設定されています。

AxeRunOptions options = new AxeRunOptions();

メソッド

setAncestry(boolean ancestry)

プロパティを設定します。 ancestry に設定すると、axe-coreエンジンはアクセシビリティ違反のある要素の完全なCSSセレクタパスを、親要素すべてを含めて表示します。これは複雑なDOM構造での違反箇所の特定に役立ちます。 true

パラメータ:

  • ancestry - 祖先情報の有効化または無効化のためのブール値

戻り値:

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

例:

AxeRunOptions options = new AxeRunOptions();
options.setAncestry(true);

setRunOnly(AxeRunOnly runOnly)

プロパティを設定し、実行するアクセシビリティルールを制限できるようにします。 runOnly これを使用して、特定の標準やルールセットにテストを集中させることができます。

important

同時に runOnlyaccessibilityStandardConfigurationOverrides内)を使用することはできません。

パラメータ:

  • runOnly - 実行するルールやタグを指定する AxeRunOnly インスタンス

戻り値:

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

例:

AxeRunOnly runOnly = new AxeRunOnly()
    .setType("tag")
    .setValues(Arrays.asList("wcag21aa", "best-practice"));

AxeRunOptions options = new AxeRunOptions();
options.setRunOnly(runOnly);

setRules(Map<String, AxeRuleOptions> rules)

プロパティを設定し、特定のアクセシビリティルールをIDで有効化または無効化できるようにします。 rules

パラメータ:

  • rules - ルールIDのマップ AxeRuleOptions インスタンス

戻り値:

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

例:

Map<String, AxeRuleOptions> rules = new HashMap<>();
rules.put("color-contrast", new AxeRuleOptions().setEnabled(false));
rules.put("aria-roles", new AxeRuleOptions().setEnabled(true));

AxeRunOptions options = new AxeRunOptions();
options.setRules(rules);

getAncestry()

プロパティの現在の値を取得します。 ancestry

戻り値:

  • boolean - 祖先プロパティの現在の値

例:

AxeRunOptions options = new AxeRunOptions();
options.setAncestry(true);
boolean ancestry = options.getAncestry(); // Returns true

getRunOnly()

現在の AxeRunOnly 設定を取得します。

戻り値:

  • AxeRunOnly - 現在のrunOnly設定、設定されていない場合はnull

例:

AxeRunOptions options = new AxeRunOptions();
AxeRunOnly runOnly = new AxeRunOnly()
    .setType("tag")
    .setValues(Arrays.asList("wcag21aa"));
options.setRunOnly(runOnly);

AxeRunOnly currentRunOnly = options.getRunOnly(); // Returns the runOnly configuration

getRules()

ルール設定の現在のマップを取得します。

戻り値:

  • Map<String, AxeRuleOptions> - 現在のルール設定、または null 設定されていない場合

例:

AxeRunOptions options = new AxeRunOptions();
Map<String, AxeRuleOptions> rules = new HashMap<>();
rules.put("color-contrast", new AxeRuleOptions().setEnabled(false));
options.setRules(rules);

Map<String, AxeRuleOptions> currentRules = options.getRules(); // Returns the rules map

toJson()

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

戻り値:

  • String - オプションのJSON文字列表現

例:

AxeRunOptions options = new AxeRunOptions()
    .setAncestry(true)
    .setRunOnly(new AxeRunOnly()
        .setType("tag")
        .setValues(Arrays.asList("wcag21aa")));

String json = options.toJson();
// Returns JSON like: {"ancestry":true,"runOnly":{"type":"tag","values":["wcag21aa"]}}

設定の検証メモ

設定する際には、次の検証ルールに注意してください: AxeRunOptions

  1. 使用時: setRules()

    • ルールマップには少なくとも1つのエントリが含まれている必要があります。
    • 各ルールの値はnullにできません。
  2. 使用時: setRunOnly()

    • プロパティは「rule」「rules」「tag」、または「tags」のいずれかでなければなりません。 type
    • プロパティには少なくとも1つの値を含んでいなければなりません。 values
    • プロパティにはnullエントリを含むことはできません。 values
  3. 排他的設定:

    • 両方を同時に使用することはできません runOnly では AxeRunOptionsaccessibilityStandard では ConfigurationOverrides

関連項目