Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 5 of 6 · Lab · 30 min · revision 3

Lab: Audit with axe, a Keyboard and a Screen Reader

Run axe over a page with real defects, fix it, then perform the keyboard and screen reader passes that automated tools cannot do, and file the issues with success criteria attached.

Contentsand lesson path

What you will learn

  • Map WCAG 2.2 AA success criteria to concrete UI checks, including the 2.2 additions such as focus not obscured, target size, dragging alternatives and accessible authentication.
  • Audit a page with automated tools (axe, Lighthouse) plus manual keyboard and screen reader passes (NVDA or VoiceOver), and file prioritized issues that cite success criteria.

Prerequisites: Semantic HTML

01. Goal and setup

This lab builds the audit workflow the skill's practice task asks for. You will take one deliberately broken page, run the axe-core engine over it in a real browser, repair every finding, and then do the two passes automation cannot do — a keyboard walk and a screen reader pass — finishing with findings filed the way a team can act on them.

You need: Node.js 22 or later with npm (the lab was run with Node 22.23). Check with node --version. Playwright downloads and manages its own Chromium. The lab pins playwright 1.64.1, whose Chromium build is 156, and @axe-core/playwright 4.14.1, which bundles axe-core 4.14.1, because the expected output depends on axe's rule set. Newer versions may list a slightly different set of rules — read the rule names, not just the counts. The lab folder:

Project layout
a11y-audit/
├── package.json           created by npm init
├── site/
│   ├── dashboard-bad.html   the provided starting page
│   └── dashboard-fixed.html your repaired copy
└── scripts/
    ├── axe-audit.mjs       the automated scan (step 2)
    └── keyboard-pass.mjs   the scripted walk (step 4)

02. Step 1: set up the folder and meet the starting page

Terminal
mkdir -p a11y-audit/site a11y-audit/scripts && cd a11y-audit
npm init -y
npm install [email protected] @axe-core/[email protected]
npx playwright install chromium

The last command downloads the Chromium build that this Playwright version expects, the first time only. Now create the starting page — a plausible team dashboard carrying six distinct defect families:

HTML · site/dashboard-bad.html (provided; fix it in step 3)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Team dashboard</title>
<style>
  body { font: 16px sans-serif; margin: 2rem; background: #ffffff; }
  .muted { color: #777777; }
  .card { border: 1px solid #dddddd; padding: 1rem; max-width: 28rem; }
  .icon-btn { border: 0; padding: 0; background: none; cursor: pointer; }
</style>
</head>
<body>
  <div class="nav">Acme dashboard | <a href="/reports.html">Reports</a></div>
  <div class="card">
    <h3>Members</h3>
    <p class="muted">5 of 8 seats used</p>
    <img src="usage-chart.png" width="320" height="160">
    <form>
      <input id="email" type="email" placeholder="Invite someone">
      <textarea id="message"></textarea>
      <button class="icon-btn" type="button">
        <svg width="16" height="16" aria-hidden="true" viewBox="0 0 16 16">
          <path d="M2 2 L14 14 M14 2 L2 14" stroke="currentColor"
                stroke-width="2"></path>
        </svg>
      </button>
      <button class="icon-btn" type="button">
        <svg width="16" height="16" aria-hidden="true" viewBox="0 0 16 16">
          <rect x="2" y="2" width="12" height="12"></rect>
        </svg>
      </button>
    </form>
  </div>
</body>
</html>

03. Step 2: run the automated scan

axe-core injects itself into the page, inspects the rendered DOM and reports rule violations. The wrapper from @axe-core/playwright needs a page from browser.newContext() — reusing a bare browser.newPage() fails with an error. Restrict the run to the WCAG 2.x tag set, so best-practice rules do not drown the conformance findings:

JavaScript · scripts/axe-audit.mjs
import { chromium } from 'playwright';
import AxeBuilder from '@axe-core/playwright';
import { pathToFileURL } from 'node:url';

const TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'];
const file = process.argv[2];
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(pathToFileURL(file).href, { waitUntil: 'load' });
const results = await new AxeBuilder({ page })
  .withTags(TAGS).analyze();
const name = file.split('/').pop();
console.log(`${name} : ${results.violations.length} violation rules`);
for (const v of results.violations) {
  const targets = v.nodes.map((n) => n.target.join(' '));
  console.log(`  ${v.id} [${v.impact}] x${v.nodes.length}`);
  console.log(`    ${targets.join(' ; ')}`);
}
await browser.close();
Terminal
node scripts/axe-audit.mjs site/dashboard-bad.html
Expected output
dashboard-bad.html : 6 violation rules
  button-name [critical] x2
    button:nth-child(3) ; button:nth-child(4)
  color-contrast [serious] x1
    p
  html-has-lang [serious] x1
    html
  image-alt [critical] x1
    img
  label [critical] x1
    #message
  target-size [serious] x2
    button:nth-child(3) ; button:nth-child(4)

Read the report on three levels. The rule id names the check; look each one up in axe's rule descriptions to see which success criterion it maps to — color-contrast maps to 1.4.3, html-has-lang to 3.1.1, image-alt to 1.1.1, button-name and label to 4.1.2, and target-size to 2.5.8. The impact ranks urgency: critical means some users are blocked, serious means significant difficulty. The count and selectors say how many elements and which ones. Six rules, eight elements — already a filing list.

04. Step 3: fix the page and re-scan

Create site/dashboard-fixed.html with all repairs applied — language declared, skip link, contrast improved, labels attached, and accessible button names:

HTML · site/dashboard-fixed.html (complete repaired page)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Team dashboard</title>
<style>
  html { scroll-padding-top: 4.5rem; }
  body { font: 16px sans-serif; margin: 2rem; background: #ffffff; }
  .skip-link { position: absolute; left: -9999px; top: auto; }
  .skip-link:focus { left: 1rem; top: 1rem; z-index: 100; background: #fff;
                     padding: 0.5rem; }
  .muted { color: #595959; }
  .card { border: 1px solid #dddddd; padding: 1rem; max-width: 28rem; }
  .icon-btn { border: 1px solid #595959; background: none; cursor: pointer;
              width: 2rem; height: 2rem; }
</style>
</head>
<body>
  <a class="skip-link" href="#main">Skip to content</a>
  <div class="nav">Acme dashboard | <a href="/reports.html">Reports</a></div>
  <main id="main" tabindex="-1">
    <div class="card">
      <h1>Team dashboard</h1>
      <p class="muted">5 of 8 seats used</p>
      <img src="usage-chart.png" width="320" height="160"
           alt="Seats used per week, rising from 3 to 5 since July">
      <form>
        <label for="email">Invite someone by email</label>
        <input id="email" type="email" name="email" autocomplete="email">
        <label for="message">Personal message (optional)</label>
        <textarea id="message" name="message"></textarea>
        <button class="icon-btn" type="button"
                aria-label="Remove the last invited member">
          <svg width="16" height="16" aria-hidden="true" viewBox="0 0 16 16">
            <path d="M2 2 L14 14 M14 2 L2 14" stroke="currentColor"
                  stroke-width="2"></path>
          </svg>
        </button>
        <button class="icon-btn" type="button"
                aria-label="Copy the invite link">
          <svg width="16" height="16" aria-hidden="true" viewBox="0 0 16 16">
            <rect x="2" y="2" width="12" height="12"></rect>
          </svg>
        </button>
      </form>
    </div>
  </main>
</body>
</html>
Terminal
node scripts/axe-audit.mjs site/dashboard-fixed.html
Expected output
dashboard-fixed.html : 0 violation rules

Zero is the exit condition for the automated part of the audit — but it is not an accessibility verdict. Look at the audit process: in the broken page the email field kept only its placeholder, and axe's label rule let it through, while a screen reader user tabbing by field gets no context for what to type. The fixed page adds an explicit <label for="email">Invite someone by email</label>. The tools verify the deterministic rules; the next two passes cover what they cannot see.

05. Step 4: the keyboard pass

A scripted walk records the tab order and focus states exactly as this skill's earlier lessons did. Write it once, run it after every fix. Before you run it, predict where Tab 2 lands once Enter has followed the skip link: on the Reports link in the navigation, or on the email field?

JavaScript · scripts/keyboard-pass.mjs
import { chromium } from 'playwright';
import { pathToFileURL } from 'node:url';

async function describe(page) {
  return page.evaluate(() => {
    const el = document.activeElement;
    if (!el) return '(none)';
    const tag = `<${el.tagName.toLowerCase()}>`;
    const id = el.id ? `#${el.id}` : '';
    const name = el.getAttribute('aria-label') ||
      el.labels?.[0]?.textContent?.trim() ||
      el.textContent?.trim().slice(0, 35) || '';
    return [tag, id, name].filter(Boolean).join(' ');
  });
}

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(pathToFileURL(process.argv[2]).href);

await page.keyboard.press('Tab');
console.log('Tab 1    ->', await describe(page));
await page.keyboard.press('Enter');
const target = await page.evaluate(() => document.activeElement.id);
console.log(`Enter    -> follows the skip link, focus on #${target}`);
for (let i = 2; i <= 5; i++) {
  await page.keyboard.press('Tab');
  console.log(`Tab ${i}    ->`, await describe(page));
}
await browser.close();
Terminal
node scripts/keyboard-pass.mjs site/dashboard-fixed.html
Expected output
Tab 1    -> <a> Skip to content
Enter    -> follows the skip link, focus on #main
Tab 2    -> <input> #email Invite someone by email
Tab 3    -> <textarea> #message Personal message (optional)
Tab 4    -> <button> Remove the last invited member
Tab 5    -> <button> Copy the invite link

The log answers the prediction: Tab 2 reaches the email field, because the walk resumes from #main, past the navigation. The script answers "where does focus go", and the Enter line reads the id of the element that really has focus, so a target without tabindex="-1" would print focus on # with nothing after it. Two judgements stay yours: is every stop visible (a screenshot after each press, or your own eyes while tabbing by hand), and is the order sensible — the log above reads top to bottom, matching the page. Unscriptable checks belong in your notes: focus hidden under the sticky header, a dialog that swallows focus, a keyboard trap.

06. Step 5: the screen reader pass

A screen reader pass needs a real screen reader: NVDA on Windows (free, from nvaccess.org) or VoiceOver on macOS. Drive the same flow three ways — reading everything from the top (NVDA: down arrow, or NVDA+Down Arrow / NVDA+A for say-all), jumping by headings (H), and jumping by form fields (F) — while asking: does every control announce a name and role, do the headings make an outline, and do live changes get spoken?

Illustrative narration · no screen reader runs on the lab machine
on dashboard-bad.html:
  ... "graphic  graphic  button button ..." (two nameless buttons,
       an unnamed graphic; fields announced only by type)
on dashboard-fixed.html:
  "Team dashboard, heading level 1"
  "Seats used per week, rising from 3 to 5 since July, graphic"
  "Invite someone by email, edit, ..."
  "Remove the last invited member, button"

The narration is illustrative, not measured: no screen reader runs on the lab machine that wrote this lab, so treat the exact phrasing as a sketch of what to listen for. The structural difference is the point — the broken page reads as a stream of anonymous graphics and buttons; the fixed page announces names, roles and the chart's message. What you hear on your machine depends on the screen reader, its verbosity settings and the browser.

07. Step 6: file the findings

Close the loop with entries a developer can act on without re-deriving anything:

One finding, as filed
issue: unnamed icon buttons on the Members card
where: /dashboard, the two 16px SVG buttons in the invite form
user impact: a screen reader user hears "button button" and cannot
  tell remove from copy; the 16px hit area misses for tremor users
criteria: 4.1.2 Name, Role, Value (A), 2.5.8 Target Size (Minimum) (AA)
detected by: axe button-name, target-size; confirmed by keyboard pass
fix: 2rem target, aria-label per action (see dashboard-fixed.html)
severity: critical (blocks the remove flow for screen reader users)

Severity follows user impact on the flow, not the rule's axe impact alone: a critical finding on a checkout outranks a serious one on a marketing page. This is the deliverable the skill's practice task asks you to produce for three flows of a real app — the same shape, scaled up.

08. Troubleshooting

09. Check your understanding

Practice check · 3 questions

Audit judgement

Three calls from the lab.

Q1. axe flags a 14 px caption set in #777777 on white, and you change it to #767676. What does the re-scan report, and why?
Q2. On a page you are auditing, an email field has only a placeholder attribute, and axe reports no label violation. What is the right call?
Q3. During an NVDA pass you jump by headings with H. What is this pass checking that axe cannot?
Practice only: not graded, not saved, not evidence.

10. Apply it

Point the same workflow at the skill's practice task. Pick one flow in an app you maintain — sign-up, search, checkout — and run the three passes on it: axe with the WCAG tags, the scripted keyboard walk, and a screen reader pass of the same flow. File every finding in the step 6 format, then fix the critical and serious ones and re-run all three passes to confirm. Add the three WCAG 2.2 manual checks the practice task names — a focus target obscured by sticky content, a drag interaction that also needs a single-pointer alternative, and a sign-in task that allows paste for a password manager — to your findings file.

11. Review prompt

Without looking back: name the three passes in the audit workflow and one thing each catches that the others cannot. Explain what a zero-violation axe run does and does not prove, list the three levels of detail in an axe report, and write from memory the fields a filed finding carries.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check