JavaとSeleniumの手順

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とSeleniumでテストを設定する

Not for use with personal data
  1. Java Watcherパッケージの新しい依存関係を pom.xml (Maven用) 依存関係セクションに追加してください (Java WatcherパッケージはMaven Centralで利用可能です):

    <dependencies>
    
    <!-- Add this dependency: -->
      <dependency>
         <groupId>com.deque.axe_core</groupId>
         <artifactId>watcher</artifactId>
         <version>4.0.0</version> <!-- Update this as needed -->
      </dependency>
    
    </dependencies>
  2. テストコードにJava Watcherのインポートを追加してください:

    import com.deque.axe_core.commons.AxeWatcherOptions;
    import com.deque.axe_core.selenium.AxeWatcher;
    import com.deque.axe_core.selenium.AxeWatcherDriver;
  3. Java Watcherのセットアップコードを追加し、個人のAPIキーとプロジェクトIDを含めてください (どちらもセキュリティと柔軟性のために環境に保存します):

    AxeWatcherOptions options =
        new AxeWatcherOptions()
            .setApiKey(System.getenv("ACCESSIBILITY_API_KEY"))
            .setProjectId(System.getenv("PROJECT_ID"));
    AxeWatcher watcher = new AxeWatcher(options);
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions = watcher.configure(chromeOptions);
    WebDriver wrappedDriver = watcher.wrapDriver(new ChromeDriver(chromeOptions));

    このコードスニペットは新しい WebDriver インスタンスを作成し、 wrappedDriver アックスコントローラーメソッドを使用するためにキャストする必要があります。

    環境に ACCESSIBILITY_API_KEYPROJECT_ID を設定し、あなたの個人的なAPIキーに設定してください(Axeアカウントの API KEYS タブで見つけられます)、およびプロジェクトID(プロジェクトを作成した際のこれらの説明の上部に示されています。または、プロジェクトページで プロジェクトを設定 を選択し、 設定から確認できます)。

  4. テストセッションの最後に、 flush()を呼び出してください:

    ((AxeWatcherDriver) wrappedDriver).axeWatcher().flush();

    を呼び出すと、 flush() テスト実行が終了し、結果が処理されユーザーに提示されることを示します。