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() テスト実行が終了し、結果が処理されユーザーに提示されることを示します。