Geek Culture
Published in

Geek Culture

Accessibility Automation testing using Deque axe-core Selenium API

What is Web Accessibility?

Web accessibility is the inclusive practice of ensuring there are no barriers that prevent interaction with, or access to, websites on the World Wide Web by people with physical disabilities, situational disabilities, and socio-economic restrictions on bandwidth and speed.

Accessibility aims to cater to people of different abilities such as:

  • Visual Impairments.
  • Physical Impairment.
  • Hearing Impairment.
  • Cognitive Impairment
  • Learning Impairment

For more detail refer to:

How we can automate this process??

As an automation engineer it came to our mind that how we can automate such things?

Let’s first understand the API!!!


Axe is an accessibility testing engine for websites and other HTML-based user interfaces. It’s fast, secure, lightweight, and was built to seamlessly integrate with any existing test environment so you can automate accessibility testing alongside your regular functional testing.

Deque axe API Documentation

Axe-core Tags

Each rule in axe-core has a number of tags. These provide metadata about the rule. Each rule has one tag that indicates which WCAG version / level it belongs to, or if it doesn’t it have the best-practice tag. If the rule is required by WCAG, there is a tag that references the success criterion number. For example, the wcag111 tag means a rule is required for WCAG 2 success criterion 1.1.1.

The experimental, ACT and section508 tags are only added to some rules. Each rule with a section508 tag also has a tag to indicate what requirement in old Section 508 the rule is required by. For example section508.22.a.

All rules have a cat.* tag, which indicates what type of content it is part of. The following cat.* tags exist in axe-core:

Results Object

The callback function passed in as the third parameter of runs on the results object.

This object has four componentsa passes array, a violations array, an incomplete array and an inapplicable array.

1) The passes array keeps track of all the passed tests, along with detailed information on each one. This leads to more efficient testing, especially when used in conjunction with manual testing, as the user can easily find out what tests have already been passed.


2) The violations array keeps track of all the failed tests, along with detailed information on each one.


3) The incomplete array (also referred to as the “review items”) indicates which nodes could neither be determined to definitively pass or definitively fail. They are separated out in order that a user interface can display these to the user for manual review (hence the term “review items”).


4) The inapplicable array lists all the rules for which no matching elements were found on the page.


Web Content Accessibility Guidelines (WCAG) criteria:

There are three levels of conformance:

  1. A — Minimum level.
  2. AA — More accessible.
  3. AAA — Even more accessible

How to Start:

AXe Selenium Integration » 4.2.2

Tools for using aXe for web accessibility testing with Selenium.

Maven Dependency:

<! —

Sample Code:

public static void checkAccessibility() {

AxeRunOnlyOptions runOnlyOptions = new AxeRunOnlyOptions();
runOnlyOptions.setValues(Arrays.asList("wcag2a", "wcag2aa"));

AxeRunOptions options = new AxeRunOptions();

AxeBuilder axe = new AxeBuilder().withOptions(options);
//Pass WebDriver Object
Results result = axe.analyze(getWebDriver());
List<Rule> violationList = result.getViolations();
System.out.println("Violation list size :"+result.getViolations().size());
for (Rule r : result.getViolations()) {
System.out.println("Complete = "+r.toString());
System.out.println("Tags = "+r.getTags());
System.out.println("Description = "+r.getDescription());
System.out.println("Help Url = "+r.getHelpUrl());

System.out.println("Inapplicable list size :"+result.getInapplicable().size());
for (Rule r : result.getInapplicable()) {
System.out.println("Complete = "+r.toString());
System.out.println("Tags = "+r.getTags());
System.out.println("Description = "+r.getDescription());
System.out.println("Help Url = "+r.getHelpUrl());

private static WebDriver getWebDriver() {
WebDriver driver = new ChromeDriver();
return driver;

For more information and detail, please refer to the below link: