Sparround

Accessibility (a11y) testing basics

Accessibility (a11y) means the product is usable by people with disabilities: screen readers, keyboard-only navigation, low vision, colour blindness, motor limitations. The standard is WCAG (levels A, AA, AAA — the practical target is usually AA).

Why it matters for QA: (1) it's a legal requirement in many countries (especially in government and finance); (2) it covers a real part of the user base; (3) a11y fixes improve general UX too (clear labels and keyboard support help everyone).

The key insight in a Playwright context: the locator getByRole('button', { name: 'Pay' }) is itself an a11y check. If that locator works, the element has a correct role and an accessible name — meaning a screen reader will also announce it as "Pay, button". Were it a <div onclick>, the locator wouldn't find it.

That's a powerful argument: using user-facing locators already buys you a layer of accessibility testing for free. Making that connection in an interview is rare and memorable.

Automated checking: the @axe-core/playwright package scans a page against WCAG rules and returns violations (a violations array: rule id, impact level, affected elements).

Typical problems it catches: images without alt text, form fields without labels, insufficient colour contrast, broken heading hierarchy, a missing lang attribute, misused ARIA.

A critical limitation — you must know this: automated tools catch roughly one third of WCAG problems. The rest needs human judgment: alt text that exists but is meaningless (alt="image1"); an illogical focus order; an error message never announced to a screen reader. Knowing that figure is a serious plus in interviews, because it shows you don't over-trust the tool.

The manual minimum (partly automatable):

  • Keyboard navigation — reaching every interactive element with Tab, a visible focus indicator, focus trapping in modals, Esc to close
  • Focus order — matching the visual order
  • A screen-reader pass — walking a critical flow (login, payment) once with NVDA/VoiceOver

A practical strategy: axe scans automated in CI for critical pages; the keyboard flow as a Playwright test; the screen-reader pass as periodic manual work.

ProblemCaught automatically?How to check
Image missing an alt attributeYesAn axe scan
alt exists but is meaningless (alt="img1")NoHuman review — the meaning of the content is judged
Insufficient colour contrastYesAn axe scan (WCAG AA ratios)
A button built as a `<div onclick>`Yesaxe — and the `getByRole` locator failing
Tab order doesn't match visual orderNoManual keyboard pass / a targeted test
Focus not trapped in a modal (escapes behind it)PartiallyA Playwright test: verifying the Tab cycle
Error message not announced to screen readersPartiallyChecking role="alert"/aria-live + a screen reader

A memorable interview answer: "I don't treat a11y as separate work — because I use `getByRole`, every test of mine already performs an element-level accessibility check; on top of that I add axe scans on critical pages and a keyboard-flow test." Then state the limitation: automated tools catch about 1/3 of the problems — that figure shows you understand the topic rather than skimming it.

📚 Sources and documentation