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 does not support full headless mode. Use --headless=new instead of --headless if you need headless operation.
  • axe Watcherはシークレットモードをサポートしていません。
  • ChromeDriverインスタンスを作成する前にconfigure()を呼び出す必要があります。
  • ChromeDriverインスタンスを作成した後にwrapDriver()を呼び出す必要があります。
  • テストの終了処理でラップされたドライバーのaxeWatcher()に対してflush()を呼び出し、すべての結果がaxe Developer Hubに送信されることを確認してください。

関連情報