App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to Automate Accessibility Testing

How to Automate Accessibility Testing

By Mohammed Waseem, Community Contributor -

Table of Contents

Creating web or mobile applications is a tedious task, but what is more challenging is making sure that it is accessible to all sorts of audiences in every way possible. The challenge of making sure that your product is accessible by all is something that is taken care of by accessibility testing. This article discusses various aspects of accessibility testing and how we can automate the entire lifecycle for efficient results. 

What is Accessibility Testing?

Accessibility testing includes testing the features of the applications that ensures everyone will be able to access the application to its full potential. This means that differently-abled people face difficulty in performing certain actions without assistance. The idea behind accessibility is to make a software that is all-inclusive, despite different abilities of the users. 

For example – overcoming the difficulties faced by a person with vision impairment while accessing any app, since the person would be unable to visuals is what accessibility concerns about. Bear in mind that accessibility testing tests specific features from the application so that it becomes accessible to all. 

One of the reasons to perform accessibility testing is – “to make it accessible to all”, and another reason is compliance followed by many countries and governments, making it mandatory for organizations to make the applications accessible to all. In order to adhere to compliance guidelines and to avoid any potential lawsuits, accessible testing is a very necessary practice that enables great success for the applications.

How do you perform Accessibility Testing?

You can perform accessibility testing both manually and using test automation. In order to make sure that all the necessary guidelines have been checked one must test their applications for the following: 

  1. Testing if the text or the labels are accessible to all – It can assess the ability of the application to check if the users will be able to see the text in case the text and labels are magnified, or minimized.  
  2. Test the contrast of the images/text – To check if the users will be able to access the applications in case the contrast is changed in the application to a higher extent. 
  3. Testing the Navigation of the application – To check if the users will be able to navigate through the entire application keeping in mind the difficulties somebody with a physical difficulty might have to face. 
  4. Testing the Style Sheets for the application – To check if in case the CSS of the application malfunctions, users will be able to comprehend the entire content displayed on the webpage. 
  5. Testing the hit area of the application – To make it more accessible to the users, the hit area of the application for more important actions must be easy to perform and interact with the application. 

People with disabilities use assistive software to use various applications like speech recognition software, screen readers, special keyboards, etc. Therefore, if an application can perform with the assistive software – it adds to the accessibility of the entire application.

Challenges with Accessibility Testing

Even with the most accurate and user-centric design for the applications, some applications may just miss out on some of the very important features that should always be taken care of in terms of accessibility. Use cases such as the user can access the applications even without being able to use the mouse, or understand the content of the application with cognitive disabilities are some of the key areas where accessibility is challenged. 

Some of the challenges that may arise with accessibility testing are as follows: 

1. Accessibility for Users with Vision Disability

While Making applications accessible for people with vision disabilities the developers have to be very careful because some users might be fully blind, or some may have color blindness or partial vision impairment. Hence, the application can be accessed even without visuals making it understandable for a visually impaired user.

Solution: Screen Readers are a great way to make software accessible to users with vision disabilities. Here the visuals of app can be heard by the user using screen readers helping them access the information.

2. Accessibility for Users with Hearing Disability 

Similar challenges can be seen for users with hearing disabilities, where the developers must take into account that any sort of interaction that involves hearing must be accessible to them.

Solution: Transcripts for Audio can help make software accessible to users with hearing disabilities. Or the use of sign language visuals can be a way to help users with hearing disabilities.

3. Accessibility for Users with Cognitive Disability 

The core challenge is content on the web applications must be easily understandable for people that may have cognitive disabilities where they might not be able to understand the content in the application.

Solution: With help of design, instructions can be delivered in a clear manner using symbols that are easy to understand for a person with cognitive disabilities as suggested by the W3C

4. Accessibility for Users with Physical Disability

The challenge is to make applications accessible for the users that may have physical disabilities, that may refrain them from operating a mouse or keyboard. 

Solution: Use Speech Recognition so that users with disabilities can control the functioning of the application with voice commands.

To make sure, all the necessary challenges and guidelines for compliance are taken care of, organizations often go for automated testing for accessibility for faster and more accurate accessibility testing. 

How to Automate Accessibility Testing?

While for testing accessibility features it is important to take real user conditions into account, for identifying all the bottlenecks in the accessibility that could hamper the user experience of the differently-abled users. Hence, testing accessibility on emulators and simulators might not suffice the purpose, and one has to test on real devices for understanding the extent of accessibility that the UI offers and how the end-user experiences it. 

Testing on physical devices might be very costly as maintaining devices in-house becomes difficult for the companies. This is where testing on a real device cloud can offer testing under real user conditions cost-effectively. Solutions like Browserstack Automate, can be used as it offers 3000+ real browser device combinations to offer a wider coverage with advanced accessibility features like screen readers. 

To perform automated accessibility testing with BrowserStack Automate, you will need to perform the following steps:

Step 1: Download the axe.min.js file. 

Step 2: Write the test script using any programming language i.e Python, Node.js, Java, PHP, Ruby, C#, Perl, etc. The following test script is written using Python. The test script will load the axe file and the accessibility tests are invoked using the axe-core library.

[python]

from selenium import webdriver

import json


desired_cap = {

        "browser": "chrome",

        "browser_version": "latest",

        "os": "windows",

        "os_version": "10",

        'build': 'Python Accessibility Test Build',

        'name': 'Axe-core testing microsoft'

        }

driver = webdriver.Remote(

    desired_capabilities=desired_cap,

    command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub'

    )

driver.get("https://www.microsoft.com")

axe_script = open('./axe.min.js', 'r')

driver.execute_script(axe_script.read())

axe_script.close()

result = driver.execute_async_script('var callback = arguments[arguments.length - 1];'

                                     'axe.run().then(results => callback(results))')

file = open("./report.json", "w")

file.write(json.dumps(eval(str(result))))

file.close()

driver.quit()

[/python]

Step 3: The results of the tests are then stored in a JSON report as seen below

Automated Accessibility Test Report

The report consists of information on metrics like:

  1. Violations: The Elements failed in the rules 
  2. Passes: The Elements passed in the rules 
  3. Incomplete: Incomplete results that were aborted for several reasons. 
  4. Inapplicable: Rules that had no matching content on the page. 

Try Accessibility Testing on Real Device Cloud

Accessibility testing is essential to make software inclusive and cater to users with alternative requirements due to specific conditions. To ensure that none of your users are unable to get the best of your site or app due to insufficient testing, include accessibility tests into the QA roadmap right from the beginning i.e. the brainstorming phase. As the world moves towards more considerate and empathetic approaches towards customer care and success, accessibility tests are poised to become an essential part of any software development pipeline.

As mentioned before, all accessibility tests on BrowserStack will be executed on real browsers and devices – both latest and older models. This includes multiple versions of all major browsers (Chrome, Edge, Firefox, Safari, IE and more) as well as thousands of desktop and mobile devices (Android, iOS, Windows). You won’t have to limit your tests with the inadequacies of emulators and simulators.

Tags
Automated UI Testing Automation Testing

Featured Articles

Quick Website Accessibility Testing Checklist

How to Test Websites with Screen Readers

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.