Anleitungen für Java und Selenium

Link to Anleitungen für Java und Selenium copied to clipboard

Konfigurieren Ihrer Tests mit Java und Selenium

Free Trial
Not for use with personal data
  1. Fügen Sie Ihrem pom.xml (für Maven) Abschnitt „Abhängigkeiten“ eine neue Abhängigkeit für das Java Watcher-Paket hinzu (das Java Watcher-Paket ist auf Maven Central verfügbar):

    <dependencies>
    
    <!-- Add this dependency: -->
      <dependency>
         <groupId>com.deque.axe_core</groupId>
         <artifactId>Beobachter</artifactId>
         <version>3.10.1</version> <!-- Update this as needed -->
      </dependency>
    
    </dependencies>
  2. Add imports for Java Watcher to your testing code:

    import com.deque.axe_core.commons.AxeWatcherOptions;
    import com.deque.axe_core.selenium.AxeWatcher;
    import com.deque.axe_core.selenium.AxeWatcherDriver;
  3. Add setup code for Java Watcher, including your project's API key (obtained from the environment as API_KEY):

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

    This code snippet creates a new WebDriver instance called wrappedDriver that you need to cast to use the axe controller methods.

  4. At the end of your testing session, call flush():

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

    Der Aufruf flush() zeigt an, dass der Testlauf beendet ist und die Ergebnisse verarbeitet und dem Benutzer präsentiert werden können.