Sai Krishnan
3 min readAug 7, 2021

What is Accessibility Testing?

Accessibility testing is a subset of usability testing, the goal here is to achieve the software product that can be used by people with disabilities.

Disabilities mainly include

  • Colour blindness
  • Complete blindness
  • Low/Impaired vision
  • Cognitive
  • Deafness

How does it actually work?

Basically, the web pages are built using web technology such as HTML, CSS, JS from there it is converted to the DOM tree and the web content is visually rendered for the user.

I,e HTML + CSS + JS -> DOM Tree -> End-user interact with web contents

The same analogy is used for the accessibility tree where the Dom tree is converted to Accessibility tree and assistive technology interacts with it for voice-over.

I,e HTML + CSS + JS -> Dom Tree -> Accessibility Tree -> Screen Reader to Voice over

Why we need to do accessibility testing?

  1. Increase website usage
  2. Enhance the brand image
  3. Makes the application accessible for the society

How to perform accessibility testing?

Accessibility testing can be done in 2 ways

  1. Manual
  2. Automation

Accessibility testing may be challenging for testers because they are unfamiliar with disabilities. It is better to work with disabled people who have specific needs to understand their challenges.

Testing can be the following,

  • Changing the color contrast of webpages and verify the contents are displayed right
  • Ensure all mouse over actions has keyboard shortcuts
  • Remove the CSS for the web pages and verify the contents are displayed right
  • When screen reader start reading the text displayed on the application make sure the right text is heard in some cases the HTML tag attribute may include.
  • There should be label field for all the input fields
  • Validate the application is accessible for different platforms
  • Color for the application is accessible for all the users.
  • Image and icons should used properly so that it is easily understood by the end user.
  • Whether a user is able to adjust audio or video controls?
  • Whether a user can override default fonts for printing and text displays
  • Whether user can adjust or disable flashing, rotating or moving displays?

Tools

There are various accessibility testing tools where we can check the accessibility of the website such as Jaws, NVDA, Colour Contrast Analyser, AXE

I did a small POC with AXE which is an accessibility engine for websites and used to automate the accessibility testing which is light weight & built seamlessly to integrate with test environments.

It is also easy to integrate with selenium and tells the accessibility violations of the websites

Integrating AXE with Selenium

Requirements:

  1. Chrome must be installed
  2. Chrome driver must be installed
  3. Java must be installed
  4. Maven must be installed

Create a Maven project -> Add the following dependencies

<dependency>
<groupId>com.deque</groupId>
<artifactId>axe-selenium</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>

Ensure that axe.min.js is located in /src/test/resources

Create a test class src/test/java (Allytest.java)

Create the script url using getResource method

private static final scriptUrl=Allytest.class.getResouce(“/axe.min.js”);

Now build the driver and use analyse method

Analyse method will analyse the application based on rules given in scriptural and return a Json

object

JSONObject responseJson=new AXE.Builder(driver.scriptUrl).analyze();

Now from the Jsonobject get an array with the key violations

JsonArray violations=responseJson.getJsonArray(“violations”);

If violations.length ==0 ,then there is no accessibility erros

Else there are some accessibility errors

Now write the erros using

AXE.writeResults(“AllyTest”,responseJson);

The script will fail if there any violations in the website and the corrections should sent to the UI developer, once it is fixed we can verify by running the test suite.