/ 2 min read
Automated accessibility checks with axe: what they found on this site
I ran axe-core in a headless browser across the main pages of this site. Most passed; two real issues did not. What it found, how I fixed it, and what an automated check cannot tell you.
In this article
Accessibility reviews tend to happen once, near launch. I wanted something I could repeat in a minute after any change, so I ran axe-core, the open source rules engine behind many accessibility tools, inside Playwright on ten pages of this site: the home page, the resume, the recruiter page, the colophon, the lab and its million row ledger, the writing index, a case study, a service page and the contact page.
The setup
await page.goto(url, { waitUntil: 'networkidle' })
await page.addScriptTag({ content: axeSource })
const violations = await page.evaluate(async () => {
const result = await window.axe.run(document, { resultTypes: ['violations'] })
return result.violations.map((v) => ({ id: v.id, impact: v.impact, nodes: v.nodes.length }))
})What it found
Eight pages came back clean. Two did not, and both findings were real.
- Critical, on the million row ledger: "Certain ARIA roles must be contained by particular parents." The header row had role="row" but sat outside the element with role="grid", so a screen reader would announce the column headers as belonging to nothing.
- Serious, on the writing index: a colour contrast failure. The small article counts next to each topic used the faintest text colour in the palette, which falls below the 4.5 to 1 contrast ratio for small text.
The fixes
The contrast fix was one class: the counts moved to the next, darker text colour. The grid fix was structural. The outer element became the grid, holding both the header row and the scrolling body (now a row group), and the keyboard handler moved up to the grid so focus and semantics live on the same element.
The fix broke a test, which was the right outcome. The end to end test picked "the first row" of the grid to check a search result; with the header inside the grid, the first row is now the header. The test now asks for the first data row, which is what it meant all along.
What an automated check cannot tell you
axe checks structure, names, roles, contrast and a long list of patterns. It cannot tell whether the focus order makes sense, whether a live region announces too much, whether a custom widget is pleasant to use with a screen reader, or whether the words on a button are clear. Those still need a person with a keyboard and a screen reader.
What it does very well is keep fixed things fixed. Two findings on ten pages is a small number, but both would have shipped, and both are the kind of regression that returns quietly when a component is refactored.
If you want to start
- Pick your ten most visited or most complex pages, not all of them.
- Run axe in the browser you already use for end to end tests, after the page has finished loading.
- Fix critical and serious findings first, and write down the ones you decide to accept, with a reason.
- Run it again after every change to a shared component.
Next article ↗
A million rows in the browser: virtualisation, a worker and one numeric sort