published fresh until

Playwright and axe: how do I keep agent UI changes accessible?

Summary When agent-written UI changes bring back accessibility problems, add an @axe-core/playwright test for each main route and new component state, using WCAG A and AA tags and asserting zero violations. Keep manual keyboard and screen-reader checks because automation catches only some issues.

Not for one-time accessibility audit of a page with Chrome DevTools MCP

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

An audit once found problems, you fixed them, and the next few agent-written components brought them back (unlabelled buttons, missing alt text, low contrast). You want a check that runs every time, not another manual audit.

What the official docs say

The Playwright accessibility testing guide uses the axe engine:

import AxeBuilder from '@axe-core/playwright';
test('home page has no detectable accessibility issues', async ({ page }) => {
  await page.goto('/');
  const results = await new AxeBuilder({ page })
    .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
    .analyze();
  expect(results.violations).toEqual([]);
});

Useful details from the guide: .include('#selector') scans one part of the page (wait for it to render first); .exclude() skips an element and its children; .disableRules([...]) turns one rule off (the rule id is in each violation); do not snapshot the whole violations array because the HTML snippets change, snapshot rule ids plus selectors instead; attach the full results to the test report for debugging; share a configured AxeBuilder through a fixture.

The guide is explicit that automated tests catch only some common problems and that many issues need manual testing, and it points to Accessibility Insights for Web for guided manual checks.

How to describe it to your agent

Add an accessibility test using @axe-core/playwright for each main route and for each new component state we add (open dialog, error form). Scan with the wcag2a, wcag2aa, wcag21a and wcag21aa tags and assert no violations. Do not use disableRules or exclude to make a test pass; if you think a rule is a false positive, list it for me instead. When a test fails, fix the markup (semantic elements, labels, contrast) rather than the test.

Mistakes to check

  • The agent silencing rules or excluding elements to get green (the same weakening problem as with any test).
  • Scanning only the initial page and missing dialogs and menus.
  • Treating zero axe violations as "accessible": keyboard order, focus visibility and screen-reader wording still need a human.

Limits

Official docs only; I did not run it on a project. An r/webdev search found no strong thread on this exact problem, so the demand signal is the recurring complaint rather than one post.

Sources

Primary source: the Playwright accessibility testing guide, read on 18 October 2026.

  • Confirms: the AxeBuilder flow with withTags for the four WCAG tags, include, exclude and disableRules, the advice to snapshot rule ids and selectors rather than the whole violations array, attaching full results to the report, sharing a configured builder through a fixture, the statement that automated checks find only some issues, and the pointer to Accessibility Insights for Web.
  • Not covered by the guide: the prompt wording and the agent-specific mistakes (silencing rules, scanning only the first page) are this thread's own advice.

Started from a post by @Playwright (Microsoft), packaged by the editor. Original post

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Playwright and axe: how do I keep agent UI changes accessible?
Summary: When agent-written UI changes bring back accessibility problems, add an @axe-core/playwright test for each main route and new component state, using WCAG A and AA tags and asserting zero violations. Keep manual keyboard and screen-reader checks because automation catches only some issues.
Copy for agent
get the whatworks thread agent-built-ui-fails-accessibility-add-axe-playwright-check and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-built-ui-fails-accessibility-add-axe-playwright-check
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks