Skip to main content

Automation Tests with Accessibility Tool using Selenium

This document provides a detailed, step-by-step way to execute your accessibility tests using TestMu AI's Accessibility Tool on HyperExecute.

note

This documentation is applicable for all supported languages for Selenium framework.

Please reach out to our support team to enable the Accessibility feature for your organization.

Prerequisites

To run the Tests on HyperExecute from your Local System, you are required:

Step-by-Step Guide to Trigger Your Test

Step 1: Configure Your Test Suite

You can use your own Selenium project to configure and test it. For demo purposes, we are using the TestNG sample repository.

Sample repo

Download or Clone the code sample for the TestNG from the TestMu AI GitHub repository to run the tests on the HyperExecute.

Image View on GitHub

If you are using your own project, make sure you update the Hub endpoint in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution.

Configure the desired capabilities based on your test requirements. For example:

test.java
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("version", "70.0");
capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
capabilities.setCapability("build", "LambdaTestSampleApp");
capabilities.setCapability("name", "LambdaTestJavaSample");

You can also use dev and beta browser versions. To generate capabilities for your test requirements, you can use our inbuilt 🔗 Capabilities Generator.

Step 2: Setup the CLI in your Test Suite

After cloning / downloading the sample repo, you need to setup the CLI and the environment variables.

Download the HyperExecute CLI

The CLI is used for triggering the tests on HyperExecute. It is recommend to download the CLI binary on the host system and keep it in the root directory of the suite to perform the tests on HyperExecute.

You can download the CLI for your desired platform from the below mentioned links:

PlatformHyperExecute CLI
Windowshttps://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe
MacOShttps://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute
Linuxhttps://downloads.lambdatest.com/hyperexecute/linux/hyperexecute

Setup Environment Variable

Now, you need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the TestMu AI Profile page.

Run the below mentioned commands in your terminal to setup the CLI and the environment variables.

export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Step 3: Add the Capabilities to enable the Accessibility

To generate accessibility reports, you need to set the accessibility: true capability in your test files.

There are two primary ways to run accessibility tests on HyperExecute:

1. On-Demand Scans (via Hooks)

For precise control over which pages are scanned, you can trigger scans manually at specific points in your test execution. This is the recommended approach to reduce test execution time on the HyperExecute grid and focus only on relevant pages.

To use this, simply enable accessibility in your capabilities:

test.java
capabilities.setCapability("accessibility", true); // Enable accessibility testing

Then, trigger the scan directly within your test script when the desired page is fully loaded:

test.java
// Execute the LambdaTest accessibility scan hook
driver.executeScript("lambda-accessibility-scan");

Note: If you do not execute the hook in your script when using this method, no accessibility reports will be generated.

2. Continuous Auto-Scanning

If you want the accessibility scanner to run automatically on every single page navigation throughout the entire test session without writing manual hooks, you must pass the accessibility.autoscan capability:

test.java
capabilities.setCapability("accessibility", true); // Enable accessibility testing
capabilities.setCapability("accessibility.autoscan", true); // Automatically scan all pages

Advanced Capabilities

You can also define other settings capabilities to refine your scan rules:

test.java
capabilities.setCapability("accessibility.wcagVersion", "wcag21aa"); // Specify WCAG version (e.g., WCAG 2.1 Level AA)
capabilities.setCapability("accessibility.bestPractice", false); // Exclude best practice issues from results
capabilities.setCapability("accessibility.needsReview", true); // Include issues that need review

Step 4: Configure your YAML file

Configure your YAML file as per your use cases using key value pairs. In this sample YAML file, we have mentioned:

  • version of the YAML file
  • Timeouts for executing your project
  • Mode of execution is Autosplit. You can also opt for Matrix or Hybrid mode.
  • Pre and Post commands
  • Reports and Artefacts that will be generated after the completion of tests
  • and other necessary YAML Parameters
HyperExecute AutoSplit YAML
loading...

Step 5: Execute your Test Suite

NOTE : In case of MacOS, if you get a permission denied warning while executing CLI, simply run chmod u+x ./hyperexecute to allow permission. In case you get a security popup, allow it from your System PreferencesSecurity & PrivacyGeneral tab.

Run the below command in your terminal at the root folder of the project:

./hyperexecute --config RELATIVE_PATH_OF_YOUR_YAML_FILE

OR use this command if you have not exported your username and access key in the step 2.

./hyperexecute --user undefined --key undefined --config RELATIVE_PATH_OF_YOUR_YAML_FILE 

Step 6: Monitor the Test Execution

Visit the HyperExecute Dashboard and check your Job status.

automation-dashboard

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles