Java and Playwright with axe DevTools

Link to Java and Playwright with axe DevTools copied to clipboard

A Playwright Java chainable API integration for axe DevTools.



See the installation guide for more information about obtaining the Playwright integration from Deque.

Add Playwright Java to your pom.xml if you have not already:

<!-- Latest Version: -->

Add @axe-core-maven-playwright dependency to your pom.xml:


Local Development

For first time installation, use the following:

mvn clean install

To run the tests:

mvn test -q

To run individual tests:

// -Dtest=<class>#<function> example:
mvn test -Dtest=PlaywrightJavaTest#shouldReturnAxeResults


The following shows a minimal example of how to set up Playwright and use it to check a page for accessibility errors:

import com.deque.html.maven.axedevtools.playwright.AxePlaywrightBuilder;
import com.deque.html.maven.axedevtools.utility.axeresults.AxeResults;
import org.junit.Test;

public class MyPlaywrightTestSuite {

    public void testMyWebPage() {
        Playwright playwright = Playwright.create();
        Browser browser = playwright.chromium()
                .launch(new BrowserType.LaunchOptions().setHeadless(true));
        Page page = browser.newPage();

        AxePlaywrightBuilder axePlaywrightBuilder = new AxePlaywrightBuilder(page);

        try {
            AxeResults axeResults = axePlaywrightBuilder.analyze();
           // Do something with axeResults
        } catch (RuntimeException e) {
            // Do something with the error

Next Steps

For more information about this integration's APIs, see the Playwright API Reference.