AxeWatcherクラス

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

Selenium Javaテストスイートにaxeアクセシビリティテストを統合するための主要なクラス

Not for use with personal data

この AxeWatcher クラスは、axe Watcher Selenium Java統合のコアコンポーネントであり、既存のエンドツーエンドテストスイートに容易にアクセシビリティテストを追加することができます。このクラスは、ブラウザオプションを構成し、 WebDriver インスタンスをラップして自動テスト中にアクセシビリティ分析を可能にするメソッドを提供します。

テストフレームワークに統合されると、axe Watcherは以下の機能を提供します。

  • テスト実行時にウェブページのアクセシビリティ問題を自動で分析
  • DOMの変更を検出するとページを再分析
  • Gitコミットをアクセシビリティの結果にリンク
  • アクセシビリティの結果をaxe デベロッパーハブに送信して追跡と分析を行う

コンストラクター

AxeWatcher(AxeWatcherOptions options)

指定されたオプションで新しい AxeWatcher インスタンスを作成します。

パラメータ:

  • options - axe Watcherの設定オプション

例:

AxeWatcherOptions options = new AxeWatcherOptions()
    .setApiKey("your-api-key-here")
    .setProjectId("your-project-ID-here")
    .setServerUrl("https://axe.deque.com");

AxeWatcher watcher = new AxeWatcher(options);

メソッド

configure(ChromeOptions chromeOptions)

を構成してaxe Watcherによるアクセシビリティテストを可能にします。 ChromeOptions このメソッドは、

important

インスタンスを作成する前に呼び出す必要があります。 ChromeDriver パラメータ:

- 既存の

  • chromeOptions インスタンスを構成する ChromeOptions 戻り値:

axe Watcherの設定が適用された新しい

  • インスタンス ChromeOptions 例外:

- ヘッドレスモードまたはインコグニートモードが有効な場合(axe Watcherはこれらのモードをサポートしていません)

  • IllegalArgumentException 例:

をラップしてアクセシビリティテスト機能を有効にします。

AxeWatcherOptions options = new AxeWatcherOptions();
options.setApiKey("your-api-key-here");
options.setProjectId("your-project-id-here");
AxeWatcher watcher = new AxeWatcher(options);

ChromeOptions chromeOptions = new ChromeOptions();
// Add any additional Chrome options here
ChromeOptions configuredOptions = watcher.configure(chromeOptions);

// Now create ChromeDriver with the configured options
ChromeDriver driver = new ChromeDriver(configuredOptions);

wrapDriver(ChromeDriver chromeDriver)

このメソッドは、 ChromeDriver が使用されて

important

をセットアップした後に呼び出す必要があります。 configure() パラメータ: ChromeDriver- ラップする

インスタンス

  • chromeDriver 戻り値: ChromeDriver アクセシビリティテスト機能が有効になったラップされた

インスタンス

  • 例外: WebDriver がこのメソッドの前に呼ばれなかった場合

例:

  • RuntimeException axe Watcherの操作のデバッグログを有効にします。これは、テスト開発中の問題解決に役立ちます。 configure() 戻り値:

メソッドチェーンのための現在の

AxeWatcherOptions options = new AxeWatcherOptions();
options.setApiKey("your-api-key-here");
options.setProjectId("your-project-id-here");

AxeWatcher watcher = new AxeWatcher(options);

ChromeOptions chromeOptions = watcher.configure(new ChromeOptions());
ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);

// Wrap the ChromeDriver
WebDriver driver = watcher.wrapDriver(chromeDriver);

// Now use the wrapped driver for testing
driver.get("https://example.com");

enableDebugLogger()

インスタンス

例:

  • The current AxeWatcher instance for method chaining

Example:

AxeWatcherOptions options = new AxeWatcherOptions();
options.setApiKey("your-api-key-here");
options.setProjectId("your-project-id-here");
AxeWatcher watcher = new AxeWatcher(options).enableDebugLogger();

注意事項と制限

  • axe Watcherは完全なヘッドレスモードをサポートしていません。 --headless=new の代わりに --headless を使用してください。ヘッドレス操作が必要な場合は
  • axe Watcherはシークレットモードをサポートしていません。
  • を呼び出す必要があります configure() を作成する前に ChromeDriver のインスタンス。
  • を呼び出す必要があります wrapDriver() を作成した後に ChromeDriver のインスタンス。
  • を呼び出します flush() ラップされたドライバーの axeWatcher() でテストの終了処理を行い、すべての結果がaxe Developer Hubに送信されることを確認します。

関連項目