Workflow recipe
Run an accessibility audit with an agent
Run an AI accessibility audit against WCAG 2.2 AA with Playwright, axe-core and an agent, add the manual checks scanners miss, and rank fixes by user impact.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
An AI accessibility audit is a split job. Pick a few key user journeys, scan every state of each with axe-core inside Playwright, and let an agent group the violations by cause and draft fixes. You do the keyboard and screen reader checks no scanner can, rank the fixes by impact on users, and keep the scans in CI.
Automated accessibility checkers find real problems quickly: missing labels, empty buttons, low contrast, broken ARIA. They also miss a lot. A checker cannot tell you that the focus jumps to the footer after closing a dialog, that an error message is never announced, or that “Click here” is useless out of context. Playwright’s own documentation says automated testing cannot detect all types of WCAG violations.
An agent helps on both sides. It runs the scanners across many pages and states, groups hundreds of raw violations into a short list of causes, and drafts fixes. You do the parts that need a person with a keyboard and a screen reader. This recipe audits a few key journeys rather than the whole site, because that is where users get stuck.
DocumentAbout 15 min
1. Pick the journeys and the standard
List three to five journeys that matter most, such as sign up, search, checkout and account settings, with the URLs and states involved (empty form, form with errors, open dialog). Write down the standard you are auditing against. WCAG 2.2 level AA is the usual target, and it is what most current procurement and legal requirements refer to.
Save this as a11y/journeys.md. The agent will work from it, and it keeps the audit to a scope you can finish.
TerminalAbout 15 min
2. Add axe-core to Playwright
Install the axe integration in your Playwright project:
npm install --save-dev @axe-core/playwrightThen write a first scan for one page, using the WCAG tags you care about:
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
const WCAG_AA = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'];
test('sign-up form has no detectable WCAG A/AA violations', async ({ page }) => {
await page.goto('/signup');
const results = await new AxeBuilder({ page }).withTags(WCAG_AA).analyze();
expect(results.violations).toEqual([]);
});
test('sign-up errors are accessible', async ({ page }) => {
await page.goto('/signup');
await page.getByRole('button', { name: 'Create account' }).click();
await expect(page.getByRole('alert').first()).toBeVisible();
const results = await new AxeBuilder({ page }).withTags(WCAG_AA).analyze();
expect(results.violations).toEqual([]);
});The second test matters: analyze() scans the page as it is at that moment, so error states, open menus and dialogs need their own scan after you trigger them. Run it with npx playwright test tests/a11y and expect failures; that is the starting point.
Claude CodeAbout 30 min
3. Have the agent scan every journey state
Ask the agent to extend the scan to every journey and state in your list, then summarise. The webapp-testing or playwright-cli skill helps it drive the browser to each state.
Grouping by cause is where the agent saves the most time. Forty violations of the same rule usually come from one shared component, and fixing the component fixes them all.
BrowserAbout 40 min
4. Do the manual checks the scanner cannot
Now test the same journeys yourself. Use the checklist from the accessibility-review skill or this short version:
- Keyboard only: can you complete each journey with Tab, Shift+Tab, Enter, Space and Escape? Is the focus always visible? Do you ever get stuck?
- Focus order: after opening and closing a dialog, where does focus go? It should return to the control that opened it.
- Screen reader: with VoiceOver or NVDA, navigate by headings and landmarks. Are form labels and error messages announced? Are status updates (such as “saved”) announced?
- Zoom and reflow: at 200% zoom and at a 320 pixel wide window, does content overlap or get cut off?
- Motion: with reduced motion enabled in your operating system, do large animations stop?
Add what you find to a11y/findings.md with a “manual” label. These findings are often the most serious, because they block a journey outright.
Claude CodeAbout 10 min
5. Rank the fix list by impact on users
Ask the agent to rank everything you have, automated and manual, by what it does to a person trying to complete the journey:
Review the ranking yourself. Agents tend to rank by axe’s severity label, which does not always match what blocks a real user.
Claude CodeAbout 30 min
6. Fix the top items, one component at a time
Work through the “blocks a journey” and “serious” groups. For each fix, ask for the smallest change, native HTML first (a real <button> instead of a clickable <div>, a <label> tied to its input), and a re-run of the relevant scan. Check each manual fix again by hand, with the keyboard or screen reader that found it.
Review the diffs closely for ARIA added on top of the problem, such as role="button" on a div without keyboard handling. That silences the scanner without helping anyone.
CIAbout 10 min
7. Keep the scans in CI
Commit the tests/a11y specs so every pull request runs them. If you cannot fix everything at once, keep the suite green by excluding a known issue with .exclude() or .disableRules() and a comment linking the ticket. Note that exclude() skips every rule for that element and its children, so keep exclusions narrow and dated.
Repeat the manual checks when a journey changes. CI catches regressions in what tools can see; it will not tell you the new dialog traps focus.
Check it worked
Verification checklist
0 of 7 done
When it goes wrong
If the scan reports nothing on a page you know has problems, check the state you scanned. Content loaded after the scan, or shown only after interaction, is not checked. Wait for the content before analyze().
If you get hundreds of violations, do not fix them one by one. Ask the agent to group them by rule and component; most come from a few shared pieces.
If contrast failures come from your design tokens, fix them in the theme, not page by page. Tell the agent where your colour tokens live.
If the agent’s fix uses ARIA to patch a non-semantic element, ask it to replace the element instead. A native control brings keyboard behaviour and announcements for free.
Variations
For a fuller audit procedure, the accessibility-engineering skill runs pinned axe-core and pa11y CLIs against a URL, then walks keyboard, screen reader and visual checks before fixing. It targets WCAG 2.2 AA.
For design reviews before code exists, the accessibility-review skill audits a page or design for contrast, keyboard navigation, touch targets and screen reader behaviour, and returns a prioritised fix list.
For exploratory checks without writing tests, connect Playwright MCP to your agent and ask it to tab through a journey and report where focus goes. Turn anything it finds into a committed test.
More testing recipes and tutorials
The same agent and browser setup lets you generate Playwright tests with AI and run exploratory testing with Playwright MCP. For where agents fit in QA work generally, read AI for QA engineers or follow the AI for test engineers learning path. More recipes like this one are in the AI workflow examples hub.
Outcome and tools
- Outcome
- A ranked list of accessibility problems on your key user journeys, the first fixes merged, and Playwright tests that stop those problems coming back.
- For
- Developers, QA engineers
- Variants for
- Claude Code, Codex, Cursor
Related
- Exploratory testing with Playwright MCP
Give a coding agent a browser through Playwright MCP, run a time-boxed exploratory charter, record findings, and turn the confirmed ones into Playwright specs.
- Generate Playwright tests with AI agents, then review them
Approve a test plan before any code exists, generate tests from it and review them like production code.
- Playwright test agents: planner, generator and healer
How Playwright's planner, generator and healer test agents work, how to set them up with Claude Code or VS Code, and how to review the tests they write for you.
- AI for QA engineers: where it helps and where it doesn't
Where it helps in test design, agent-written tests and self-healing, where it does not, and the testing skills worth building.
- AI for test engineers
An AI course for testers: apply generative AI to everyday test automation, from AI-assisted test design to generating, healing and reviewing Playwright tests.