Skip to content

Instantly share code, notes, and snippets.

@MatMoore
Last active May 28, 2025 10:16
Show Gist options
  • Save MatMoore/4a40376e2ebd6a4fb3259c4876377474 to your computer and use it in GitHub Desktop.
Save MatMoore/4a40376e2ebd6a4fb3259c4876377474 to your computer and use it in GitHub Desktop.
Automated accessibility testing with playright (python)

axe

https://pypi.org/project/axe-playwright-python/

How Slack use axe in playright:

  • Playwright test lands on a page/view
  • Axe analyzes the page
  • Pre-defined exclusions are filtered out
  • Violations and artifacts are saved to a file

It was important to make sure the same view wasn’t being analyzed twice in one test, or potentially twice across multiple tests with the same UI flow. Duplication like this would result in unnecessary error messages and saved artifacts, and slow down our tests. We were also careful to place our Axe calls only after the page or view had fully loaded and all content had rendered.

other testing in playright

accessibility tree

https://playwright.dev/python/docs/aria-snapshots

at some point they deprecated an older API and said just use Axe, there are some examples in this thread on why that didn't make sense microsoft/playwright#16159

keyboard navigation / inputs

https://playwright.dev/python/docs/api/class-keyboard

prefers-colors-scheme

https://playwright.dev/docs/api/class-page#page-emulate-media

what can and can't be tested

other tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment