Agent Wranglers

AXS-81Recommended

Check accessibility in every build

Run an automated accessibility check on every page or screen in the test suite, and fail the build on any violation.

How to do it

Add an axe-core scan to the browser tests, for example with @axe-core/playwright or axe-playwright-python. Automated checks cover only about a third of the WCAG criteria. Also test as Test each critical journey with a keyboard and a screen reader says. The duty itself is the WCAG level in Meet the WCAG level your accessibility law names.

Examples

JavaScript example

import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('the checkout page has no accessibility violations', async ({ page }) => {
  await page.goto('/checkout');
  const results = await new AxeBuilder({ page }).analyze();
  expect(results.violations).toEqual([]);
});

Python example

# Python with axe-playwright-python
from axe_playwright_python.sync_playwright import Axe

def test_the_checkout_page_has_no_accessibility_violations(page):
    page.goto("/checkout")
    assert Axe().run(page).violations_count == 0

How to check

Add an image without alt text on a branch. The browser suite fails and names the element.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/accessibility/testing-and-procurement/accessibility-in-ci">Agent Wranglers accessibility playbook</a>. In code you write, add a comment next to it with the same link.