Features
< Back to Blog Overview

Accessibility Testing

2021-04-30
Automated Accessibility Testing with TestingBot
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on HackerNews

Automated Accessibility Testing allows you to test if your website is accessible to all types of users.


The popular accessibility testing framework Axe allows for testing your website for all kinds of accessibility issues. The framework includes checking if your website adheres to the Web Content Accessibility Guidelines (WCAG), as well as section 508 guidelines.

Why should I consider accessibility Testing?

Testing for accessibility issues allows you to make sure that your website is working well for all types of users. Some of your visitors might have issues with color contrasts, or use a screen-reader to digest your website.


If some of your DOM elements lack sufficient color contrast, these users might have a hard time reading your website.
People using screen readers might have trouble reading parts of your website, as some DOM elements might have similar titles, alt tags or aria-labels.
Alternative texts on your webpage, repeating the same content over and over, might confuse your visitors with screen readers.


By integrating accessibility testing in your test process, you'll ensure that your customers can use your product in the best way possible.


The principles of Accessibility Testing

The WCAG stipulates four main principles, stating that content on webpages should be POUR: Perceivable, Operable, Understandable and Robust.


Perceivable

The contents on your webpage must be presented to your users in a way that they can perceive, it must be visible to their senses.


This means you should provide text alternatives, adaptable content (content that can be presented in different ways) and make content distinguishable (foreground/background colors, audio, ...).


Operable

The UI of your webpage should not require interaction that a user cannot perform. Make sure your elements can be used with keyboard only, make your webpages navigable and provide enough time to your users to digest your content.


Understandable

Make the content on your webpages easy to understand. Ensure your UI operates in a predictable way.


Robust

Maximize compatibility of your webpage with current and future browsers, screen readers and other user agents, including assistive technologies.


Start using Accessibility Testing

The Axe framework comes as a javascript file, which can be injected in the page that you are testing. Axe will then report the results back to your test case, allowing you to verify if any issues are present on your page.


See a simple example below:


Copy code
const webdriver = require('selenium-webdriver');
const fs = require('fs')

const testingbotKey = "[your-testingbot-key]";
const testingbotSecret = "[your-testingbot-secret]";

const capabilities = {
    'browserName': 'firefox',
    'platform': 'WIN10',
    'version': 'latest',
    'client_key': testingbotKey,
    'client_secret': testingbotSecret,
    'name': 'Accessibility Test'
};

async function runAccessibilityTest () {
  let driver = new webdriver.Builder()
    .usingServer('https://' + testingbotKey + ':' + testingbotSecret + '@hub.testingbot.com/wd/hub')
    .withCapabilities(capabilities)
    .build();
  await driver.get("https://testingbot.com");
  const data = await fs.readFileSync('path/to/axe.min.js', 'utf8')
  await driver.executeScript(data.toString());
  let result = await driver.executeScript('let result; await axe.run().then((r)=> {result=r}); return result;');
  await fs.writeFileSync('path/to/report.json', JSON.stringify(result));
  await driver.quit();
}
runAccessibilityTest();

This NodeJS example will inject the path/to/axe.min.js file in the current webpage and report the results back to path/to/report.json for verification.


The results will contain the following structure:

  • violations includes the rules that were violated and need to be fixed.
  • passes the rules that have passed successfully.
  • incomplete incomplete results, either due to an error or aborted test
  • inapplicable no matching content was found for these rules.

For more information about accessibility testing, including more examples, please see our Accessibility Testing Documentation.

TestingBot Logo

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.

Other Articles

Puppeteer Testing in the Cloud

TestingBot has been providing a Selenium-based cloud service since 2012. We started with offering a Selenium RC compatible grid and added Selenium ...

Read more
Run Cypress tests on TestingBot's Browser Grid

TestingBot has released testingbot-cypress-cli, a CLI program that allows you to run your Cypress Automated tests on TestingBot's browser grid. Wh...

Read more
Run TestCafe tests on TestingBot's Browser Grid

Today we're releasing testcafe-browser-provider-testingbot, a plugin for TestCafe. TestCafe is a NodeJS framework to do automate end-to-end web t...

Read more
Selenium 4 (Alpha) Testing on TestingBot

TestingBot now supports Selenium 4 (Alpha) testing on its Selenium grid! Even though Selenium 4 is still only available as an alpha version, we've...

Read more
Test on macOS Big Sur and Safari 14

macOS Big Sur Preview 1 We have added Apple's upcoming OS to our list of platforms. Apple announced this next new major macOS release in its lates...

Read more
Take control of a physical iOS device via VNC

Today we're excited to open-source a feature that we've been using in production for the last 3 years: an iOS VNC Server. This will allow you to c...

Read more