Most accessibility problems that ship to production are not subtle. They are an <img> with no alt attribute, an icon-only button with no aria-label, body text in #9ca3af on a #f3f4f6 background, a form input whose visual label is a <div> three nodes away instead of a <label>, or a modal that trapped focus inside a closed overlay. None of those require a human accessibility specialist to spot — they are deterministic DOM and computed-style facts that a headless browser can check in two seconds on every pull request.
When I built AuditBloc — a web accessibility and compliance scanner that evaluates live URLs for WCAG 2.1 Level A/AA violations, GDPR cookie behaviors, and AI disclosure signals — the core scanning engine was built on Playwright and Deque's axe-core. This guide walks through how to wire that same stack into your own test suite, how to scan interactive UI states that naive URL crawlers miss, what automated tools genuinely cannot catch, and how we combined accessibility and privacy checks in AuditBloc.
What Automated Accessibility Testing Catches (and What It Cannot)
Let's start with an honest number, because the accessibility tooling market is full of dishonest ones. Deque's own research on millions of axe-core scans shows that automated testing catches roughly 30–40% of WCAG success criteria by count, and up to ~50% of actual issue volume found in real-world audits (because the rules automation can check — contrast, missing labels, missing alt text, invalid ARIA — happen to be the mistakes developers repeat hundreds of times per site).
Why can't automation catch 100%? Because WCAG criteria fall into three buckets:
- Deterministic structural and style rules (Automated): Does every
<img>have analtattribute? Does every<input>have an accessible name via<label>,aria-label, oraria-labelledby? Is the computed foreground/background contrast ratio at least4.5:1for normal text and3:1for large text? Areidattributes unique? Arearia-*attributes valid for the element's role?axe-corecatches these with a near-zero false-positive rate. - Contextual semantic accuracy (Requires human review):
axe-corecan verify that<img alt="chart">has a non-emptyaltstring. It cannotknow that the image is actually a Q3 revenue chart whose key takeaway ("Q3 revenue up 18% YoY") is completely missing from the alt text, or conversely that a decorative background flourish should havealt=""so screen readers skip it. - Interaction and reading-order ergonomics (Semi-automated / manual): Can a keyboard-only user complete the multi-step checkout without focus jumping to the footer when a step changes? Does the screen reader announce dynamic toast errors via an
aria-liveregion at the right moment? You can write targeted Playwright tests for specific keyboard flows, but a generic rule scanner cannot invent your user journey.
Understanding that split is liberating: you use Playwright + axe-core to eliminate the 50% of mechanical regressions automatically in CI, which frees your manual keyboard and screen-reader pass to focus on real user flows instead of hunting for missing alt tags. And with the ADA Title II WCAG 2.1 AA compliance deadline set for April 2027, having automated regression gates in CI is now a baseline procurement expectation.
Setting Up Playwright and @axe-core/playwright
If you already have a Next.js or React app, install Playwright and the official Deque Playwright integration:
npm install -D @playwright/test @axe-core/playwright
npx playwright install --with-deps chromiumWhy run axe-core inside Playwright instead of running a static HTML linter or jsdom test? Two huge reasons:
- Real CSS layout and computed contrast: Color contrast rules (WCAG 1.4.3) need a real browser rendering engine to resolve CSS custom properties, inherited font sizes, gradients, and stacking contexts.
jsdomdoes not compute layout or real painted styles, so contrast checks are blind or inaccurate outside a real browser. - Hydrated client-side UI: Modern React and Next.js apps render portals, radix/headless-ui dialogs, client-loaded menus, and dynamic state after hydration. Playwright runs real Chromium, waits for network and hydration settle, and can click into interactive states before running the scan.
Here is a clean, production-ready accessibility test file (tests/a11y.spec.ts) that scans your core routes against WCAG 2.0 and WCAG 2.1 Level A and AA rules:
import { test, expect } from "@playwright/test"
import AxeBuilder from "@axe-core/playwright"
const PUBLIC_ROUTES = ["/", "/about", "/projects", "/services", "/blog", "/contact"]
for (const route of PUBLIC_ROUTES) {
test(`WCAG 2.1 AA scan passes on ${route}`, async ({ page }) => {
await page.goto(route, { waitUntil: "networkidle" })
const results = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "best-practice"])
.analyze()
// Format violations clearly in CI output when a test fails
const summary = results.violations.map((v) => ({
id: v.id,
impact: v.impact,
description: v.description,
nodes: v.nodes.map((n) => ({
target: n.target,
failureSummary: n.failureSummary,
})),
}))
expect(summary, `Accessibility violations on ${route}`).toEqual([])
})
}The Secret Most Scanners Miss: Scanning Interactive States
If you only run new AxeBuilder({ page }).analyze() immediately after page.goto(), you have only tested the resting state of the page. Your mobile navigation drawer, search modal, dropdown menus, and form validation error messages are not even in the DOM yet — or they have display: none / aria-hidden="true", which tells axe-core to skip them.
In Playwright, you can drive the UI into each interactive state and scope or re-run the scan:
test("mobile navigation drawer and contact form error states are accessible", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 })
await page.goto("/contact")
// 1. Open mobile navigation menu and scan the open sheet
const menuButton = page.getByRole("button", { name: /open navigation menu/i })
await menuButton.click()
await expect(page.getByRole("dialog")).toBeVisible()
const menuScan = await new AxeBuilder({ page })
.include('[role="dialog"]')
.withTags(["wcag2a", "wcag2aa", "wcag21aa"])
.analyze()
expect(menuScan.violations).toEqual([])
// Close mobile menu with Escape and verify focus returns to trigger
await page.keyboard.press("Escape")
await expect(menuButton).toBeFocused()
// 2. Trigger form validation errors and scan the form in its error state
await page.getByRole("button", { name: /send message/i }).click()
const formScan = await new AxeBuilder({ page })
.include("form")
.withTags(["wcag2a", "wcag2aa", "wcag21aa"])
.analyze()
expect(formScan.violations).toEqual([])
})Look at what that 30-line test verifies: not only does it run axe-core against the open dialog and the error-state form (catching low-contrast red error text or missing aria-describedby links), it also asserts WCAG 2.1.2 / 2.4.3 keyboard behavior — pressing Escape closes the dialog and returns focus to the button that opened it.
The 5 Violations You Will Hit First (and How to Fix Them in React/Next.js)
Across hundreds of scans run through AuditBloc, these five axe-core rule IDs account for the overwhelming majority of failures on modern React and Tailwind sites:
color-contrast(Serious): Tailwind classes liketext-slate-500on a dark card (`bg-slate-900`) ortext-slate-400on a white background often land around3.2:1, failing the4.5:1AA requirement for body text. Bump secondary body copy on dark surfaces totext-slate-300ortext-slate-400against near-black (`#020106`), and reserve dimmer shades strictly for decorative borders.button-nameandlink-name(Critical): Icon-only buttons (hamburger menu, theme toggle, carousel prev/next, social links) with an<svg>inside and no text. Fix by adding an explicitaria-label="Previous testimonial"on the<button>andaria-hidden="true"on the<svg>.label(Critical): Search bars or newsletter inputs that rely onplaceholder="Search..."with no<label>. Placeholders disappear as soon as the user types and are not a reliable accessible name. Wrap the input in a<label>with a<span className="sr-only">Search articles</span>.heading-order(Moderate): Jumping from<h1>straight to<h3>or<h4>because you wanted a smaller font size. In Tailwind, heading level and visual size are completely decoupled — use the semantically correct<h2>and style it withtext-sm font-semiboldif the design calls for a compact subheading.region/ Landmark structure (Moderate): Content floating outside<header>,<nav>,<main>, or<footer>landmarks, or multiple<nav>elements on the same page without distinctaria-labelattributes (e.g.,aria-label="Main navigation"vs.aria-label="Footer navigation").
Running Accessibility Scans in GitHub Actions
An accessibility test suite only protects you if it blocks regressions on pull requests. In GitHub Actions, build your Next.js production output, start the server, and run the Playwright accessibility spec:
name: Accessibility CI
on: [pull_request]
jobs:
a11y:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run build
- run: npx playwright test tests/a11y.spec.tsIf you are introducing automated accessibility testing into a legacy codebase that already has 80 violations, don't let that stop you from turning on CI today. Gate CI on critical and serious impacts first, or use .exclude("#legacy-widget") with a tracked issue ticket while you burn down the backlog route by route.
How AuditBloc Combines WCAG and GDPR Cookie Checks in One Pass
When we architected AuditBloc, we realized that the exact same headless Playwright browser session needed for a WCAG audit is also the ideal vantage point for auditing GDPR / ePrivacy cookie behavior:
- Pre-consent cookie and network inspection: Before clicking anything on the page, Playwright inspects
context.cookies(),localStorage, and outbound network requests on initial load. If analytics or advertising trackers fire before the user has interacted with a consent banner, AuditBloc flags a pre-consent tracking issue with the exact cookie names and domains. - Consent banner symmetry and accessibility:If a cookie banner is present, is it keyboard-reachable? Does it offer a clear reject/decline path alongside accept, or is "Reject" buried three screens deep with
2.1:1contrast? Because the banner is in the live DOM on first load,axe-coreand our custom banner heuristics evaluate it in the same pass. - Structured remediation report: Raw
axe-coreJSON output is great for developers but overwhelming for product owners. AuditBloc groups findings by severity (Critical,Serious,Moderate,Minor), maps each to its WCAG 2.1 success criterion, and highlights the exact DOM selector and remediation steps.
Frequently Asked Questions
What percentage of WCAG issues can axe-core catch automatically?
Roughly 30% to 40% of WCAG criteria by count, and up to 50% of common real-world violations by volume. The remaining criteria require human judgment on reading order, alt-text accuracy, and keyboard usability.
Does passing an automated axe-core scan make a website ADA compliant?
No. Passing an automated scan eliminates the machine-detectable violations that trigger most demand letters, but full WCAG 2.1 AA compliance also requires manual keyboard and screen-reader verification.
Why run axe-core inside Playwright instead of a static HTML checker?
Playwright renders the real page in a headless browser, executes client-side JavaScript, computes actual CSS contrast ratios, and lets you open modals, drawers, and form error states before running axe-core.
You can read the full AuditBloc case study or try the live scanner at auditbloc.taylancetech.com. If your team needs an accessibility audit, automated CI guardrails, or WCAG 2.1 AA remediation on a React or Next.js application, get in touch.



