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

axeのアクセシビリティテストをSelenium Javaテストスイートに統合するためのメインクラス(Playwrightを使用する場合はAxeWatcherPlaywrightを使用)

Not for use with personal data

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

テストフレームワークに統合されると、Axe Watcherは次のことを行います。

  • テストが実行されるときに、ウェブページのアクセシビリティ問題を自動で分析します
  • DOMの変更が検出されると再分析を行います
  • Gitコミットをアクセシビリティ結果にリンクします
  • アクセシビリティの結果をAxe Developer Hubに送信して、追跡と分析を行います

コンストラクタ

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)

ChromeOptionsを設定して、Axe Watcherによるアクセシビリティテストを有効にします。

important

このメソッドは、ChromeDriverインスタンスを作成する前に呼び出す必要があります。

パラメータ:

  • chromeOptions - 設定する既存のChromeOptionsインスタンス

戻り値:

  • Axe Watcherの設定が適用された新しいChromeOptionsインスタンス

例外:

  • IllegalArgumentException - ヘッドレスまたはシークレットモードが有効な場合(Axe Watcherはこれらのモードをサポートしていません)

例:

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 - このメソッドが呼ばれる前に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()

Axe Watcherの操作に関するデバッグログを有効にします。これは、テストの開発中に問題をトラブルシューティングするのに役立ちます。

戻り値:

  • メソッドチェーンに使用するための現在のAxeWatcherインスタンス

例:

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はシークレットモードをサポートしていません。
  • ChromeDriverインスタンスを作成する前にconfigure()を呼び出す必要があります。
  • ChromeDriverインスタンスを作成した後にwrapDriver()を呼び出す必要があります。
  • すべての結果がAxe Developer Hubに送信されることを確実にするために、テストのティアダウンでラップされたドライバーのaxeWatcher()に対してflush()を呼び出します。

関連情報