Automated accessibility testing

TODO: Starter content. This content should be reviewed and restructured. The links need to be checked and updated. Some info/resources can be moved to the topics (and linked to) Standards and best practice.

WCAG 2 AA automated validation

The generated DOM, the front end of your web project, must conform to WCAG 2 AA. You can use automated validation to get a limited scope of your success at this.

Recommended:

More tools:

Automated testing

The big difference between PHP and JavaScript code standard checks and accessibility checks is that the accessibility checks need to be performed on the generated DOM, not on the code base. You need to run checks on a working WordPress site. This can be done using automation that sets up your environment dynamically, but still requires a fully built and run installation.

There are several command line tools for automated testing like aXe-cli and pa11y.

Automated accessibility testing doesn’t catch all the issues, rarely more than 30%. Testing in the browser and manual keyboard testing still needs to be part of your workflow.

Setup for aXe-cli

Install axe-core for CLI first:

npm install axe-cli -g
npm install chromedriver –g`

Then run axe in the command line:

axe url -b c

The url can be any url, also a local one. You get a report of the accessibility issues for that url. The -b stands for browser, c for chrome, as this browser gives the best results (better than the default PhantomJS). You will get the errors and warnings in your console.

You can provide more (space separated) urls to the command like

axe url url2 url3 -b c

or call a file with urls like:

axe $( cat list-of-urls.txt ) -b c

Note: You can run axe-cli on more than one url in one command, but axe-cli is not build to run on a large amount of urls or on a complete site, axe-cli is not a crawler. Deque Labs recommends to use the axe-webdriverjs, a chainable aXe API for Selenium’s WebDriverJS for testing on a large amounts of urls.

Setup for pa11y

The setup for pa11y is well documented in the GitHub repository.

Browser Toolbars & Toolkits