Capture Violation Screenshots

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

Save screenshots when accessibility violations are found

Not for use with personal data

When Axe Watcher finds accessibility violations, it can capture a screenshot of the page at that moment. Screenshots are uploaded to Axe Developer Hub, and can optionally be saved to a local directory for inspection during development.

Screenshot capture is available for all JavaScript and TypeScript integrations (Playwright Test, Cypress, WebdriverIO, and Puppeteer) and both Java integrations (Selenium and Playwright).

important

Viewing uploaded screenshots in the Axe Developer Hub interface is currently only available for mobile projects. Support for viewing web and Java screenshots in Axe Developer Hub is planned but not yet available, so until then, use local screenshot saving to review captured screenshots.

Enable Screenshot Capture

JavaScript or TypeScript:

Set takeScreenshots: true in your AxeConfiguration:

axe: {
  takeScreenshots: true
}

Java:

Call setTakeScreenshots(true) on AxeWatcherOptions:

AxeWatcherOptions options = new AxeWatcherOptions()
    .setApiKey(System.getenv("ACCESSIBILITY_API_KEY"))
    .setProjectId(System.getenv("PROJECT_ID"))
    .setTakeScreenshots(true);

Save Screenshots Locally

You can also save screenshots to a directory on your local machine. This is useful for reviewing violations while tests are running locally, without opening Axe Developer Hub.

JavaScript or TypeScript:

Add screenshotDir to your AxeConfiguration:

axe: {
  takeScreenshots: true,
  screenshotDir: './axe-screenshots'
}

Java:

Call setScreenshotDir() on AxeWatcherOptions:

AxeWatcherOptions options = new AxeWatcherOptions()
    .setApiKey(System.getenv("ACCESSIBILITY_API_KEY"))
    .setProjectId(System.getenv("PROJECT_ID"))
    .setTakeScreenshots(true)
    .setScreenshotDir("./axe-screenshots");

setScreenshotDir has no effect unless setTakeScreenshots(true) is also set. Relative paths are resolved against the JVM working directory. If the directory does not exist, Watcher creates it. If directory creation or file writing fails, a warning is logged and the test suite continues.

Screenshots are written using this filename pattern: YYYYMMDDTHHmmssSSS-{id}.png. The timestamp prefix keeps files sorted by capture time and prevents collisions when multiple screenshots are taken in the same test run.

See setTakeScreenshots and setScreenshotDir in the Java API reference for full parameter details.