Curious Minds

Clear answers to science and history questions

In Test vs Out of Test Accessibility Automation

· 6 min read · Science

In test vs out of test accessibility automation refers to where accessibility checks run in the software development lifecycle: in-test automation runs assertions within your functional test suite (e.g., Selenium, Playwright) at build time, while out-of-test automation runs scans and audits outside the test suite, typically via CI jobs, browser extensions, or dedicated tools. The key difference is timing and purpose: in-test checks catch issues during development and regression cycles, while out-of-test checks provide broader, more comprehensive coverage of the entire rendered page and can run continuously.

Background: Why Accessibility Automation Exists

Manual accessibility audits are thorough but slow and expensive. Automated tools fill the gap by catching a subset of accessibility issues—typically 30-50% of WCAG failures—quickly and consistently. The two approaches evolved from different needs: developers wanted immediate feedback during coding (in-test), while QA and compliance teams wanted full-page audits without needing to write test code (out-of-test).

How In-Test Accessibility Automation Works

In-test automation integrates accessibility assertions directly into your existing functional tests. For example, in a Playwright test, you might add a line like expect(page).toPassAxe() after loading a page. The test runner executes the axe-core library (or similar) against the current DOM, and if any violations are found, the test fails.

  • Where it runs: Inside your test suite, alongside functional checks.
  • What it catches: Issues on the specific page or component state the test visits.
  • When it runs: During development, in CI on every pull request, or in nightly regression runs.
  • Examples: Checking a login form after a failed submission, verifying a modal dialog after opening it, testing a dropdown menu in both expanded and collapsed states.

The main advantage is context: you can test accessibility at the exact moment a user interacts with a component, such as after an error message appears or after a dynamic update. This catches issues that static scans miss because the DOM is in a specific state.

How Out-of-Test Accessibility Automation Works

Out-of-test automation runs accessibility scans independently of your functional tests. This includes:

  • CI jobs: A separate pipeline step that crawls your staging site and runs a full-page audit using tools like Lighthouse CI, pa11y, or axe-core via a CLI.
  • Browser extensions: Developers or QA manually open a page and run a scan (e.g., axe DevTools, WAVE).
  • Standalone scanners: Tools that crawl multiple URLs and generate reports, often integrated with issue trackers.

These tools typically analyze the entire rendered HTML, including elements that are present but not currently visible or interactive. They produce a list of violations with severity levels, affected elements, and links to WCAG criteria. The output is often a report rather than a pass/fail test.

Key Differences in Coverage and Workflow

The most significant difference is what gets tested. In-test automation only checks the pages and states your functional tests happen to visit. If you have a page with 10 different user roles, but your test only logs in as one role, the other nine role-specific views are never checked. Out-of-test automation can crawl all URLs and even simulate different viewport sizes, giving broader coverage.

However, out-of-test scans often miss issues that require interaction. For example, a tooltip that appears on hover, an accordion that expands on click, or a form error that shows only after submission—these are invisible to a static crawl. In-test automation can trigger those interactions and then check accessibility.

Another difference is speed and feedback. In-test checks run in milliseconds and fail the build immediately, giving developers instant feedback. Out-of-test scans can take minutes to crawl a site, so they typically run less frequently (e.g., nightly) and produce a report that needs triage.

How to Choose Between the Two

Most mature teams use both. Here’s a practical approach:

  1. Start with out-of-test: Run a full-site scan to identify systemic issues (e.g., missing alt text, low contrast, missing form labels). Fix those first.
  2. Add in-test checks for critical user flows: For your most important journeys (checkout, login, search), add accessibility assertions to the functional tests that already exist.
  3. Use out-of-test for regression: Schedule a nightly crawl to catch new issues introduced by content updates or code changes.
  4. Combine with manual testing: Neither approach replaces manual testing with assistive technology (screen readers, keyboard-only).

If you have limited resources, start with out-of-test automation because it gives the most coverage per hour of setup. Then add in-test checks to the specific flows where you know dynamic content exists.

Common Problems and Misconceptions

Misconception: “Automated checks mean we’re WCAG compliant.” False. Automated tools only catch a fraction of WCAG success criteria. Many require human judgment (e.g., whether alt text is accurate, whether a heading hierarchy makes sense).

Misconception: “In-test is better because it’s more accurate.” Not necessarily. In-test checks are more precise for the state they test, but they can give a false sense of security if you only test happy paths. A page might pass an in-test check on the default state but fail when a user opens a date picker.

Common problem: False positives. Both methods can flag issues that are actually fine. For example, a contrast check might fail on a disabled button that is exempt under WCAG. You’ll need to configure rules or add annotations.

Common problem: Test maintenance. In-test checks add to your test suite’s runtime and can break when the DOM changes. Out-of-test scans require a stable URL structure and may need authentication setup for protected pages.

Costs and Tooling Considerations

In-test automation uses open-source libraries like axe-core, which is free. However, the cost is in developer time to write and maintain the assertions. Out-of-test tools range from free (Lighthouse CI, pa11y) to commercial platforms that offer dashboards, scheduling, and issue tracking. The commercial tools often provide better reporting and integration with project management software, but they add a subscription cost.

Both approaches require someone to review the results. Automated reports still need a human to triage false positives, prioritize fixes, and verify that the fix actually resolves the issue. This ongoing review is often the hidden cost.

Frequently Asked Questions

Can I use the same tool for both in-test and out-of-test?

Yes. axe-core, for example, has a Node.js API for in-test assertions and a CLI for out-of-test scans. Many teams standardize on one engine to keep results consistent, even though the execution contexts differ.

Which catches more issues: in-test or out-of-test?

Out-of-test catches more unique issues because it scans more pages and states. However, in-test catches issues that only appear after interaction. A study by the W3C found automated tools catch about 30-50% of WCAG failures; the split between in-test and out-of-test depends on your coverage, but out-of-test generally finds more because it scans the whole page.

Do I need both if I have a small site?

If your site has fewer than 10 pages and no dynamic content, out-of-test alone may suffice. But if you have forms, modals, or single-page apps, in-test checks on those interactions are worth the extra effort.

How do I handle protected pages (login required) for out-of-test scans?

Most out-of-test tools support authentication via environment variables, session tokens, or a pre-login step. For example, you can set a cookie or use a headless browser to log in before crawling. Some commercial tools have built-in auth handling.

What is the biggest mistake teams make with accessibility automation?

Treating it as a one-time check rather than a continuous process. Accessibility degrades with every code change, so automation must run regularly. Also, relying solely on automated results without manual testing with real screen readers leads to false confidence.

Can I use in-test automation for a single-page app with client-side routing?

Yes, and it’s actually recommended. Since the DOM changes without a full page reload, in-test assertions can be placed after each route change to ensure the new view is accessible. Out-of-test crawlers may miss client-side routes unless they are configured to execute JavaScript and wait for rendering.

In this article
  1. Background: Why Accessibility Automation Exists
  2. How In-Test Accessibility Automation Works
  3. How Out-of-Test Accessibility Automation Works
  4. Key Differences in Coverage and Workflow
  5. How to Choose Between the Two
  6. Common Problems and Misconceptions
  7. Costs and Tooling Considerations
  8. Frequently Asked Questions