Java Playwright Troubleshooting

Link to Java Playwright Troubleshooting copied to clipboard

This document describes problems you might encounter when using the Java Playwright integration. For troubleshooting tips with the other Java integrations, see Java Troubleshooting

Version 4.3.0 and above of the axe-core integrations use a new technique when calling AxePlaywrightBuilder.analyze() which opens a new window at the end of a run. Many of the issues outlined in this document address common problems with this technique and their potential solutions.

Having Popup blockers enabled

Popup blockers prevent us from opening the new window when calling AxePlaywrightBuilder.analyze(). The default configuration for most automation testing libraries should allow popups. Please make sure that you do not explicitly enable popup blockers which may cause an issue while running the tests.

AxePlaywrightBuilder.setLegacyMode(boolean legacyMode)

If for some reason you are unable to run the new AxePlaywrightBuilder.analyze technique without errors, axe provides a new chainable method that allows you to run the legacy version of AxePlaywrightBuilder.analyze. When using this method axe excludes accessibility issues that may occur in cross-domain frames and iframes.


AxePlaywrightBuilder.setLegacyMode is deprecated and will be removed in v5.0. Please report any errors you may have while running AxePlaywrightBuilder.analyze so that they can be fixed before the legacy version is removed.


The following example shows a complete example of using the Java Playwright integration:

import com.deque.axecore.playwright.AxePlaywrightBuilder;
import com.deque.axecore.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)
        // Set legacyMode

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