Automation Tests with Accessibility Tool using Selenium
This document walks you through the process of evaluating the accessibility of your website through the execution of automated tests using LambdaTest's Accessibility Tool.
Compatible only with Chrome and Edge browser versions >= 90.
Prerequisites
- Your LambdaTest Username and Access key
- Setup your local machine as per your testing framework.
Step-by-Step Guide to Trigger Your Test
Step 1: Setup Your Test Suite
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
Download or Clone the code sample from the LambdaTest GitHub repository to run your tests.
View on GitHubIf 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:
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 generate capabilities for your test requirements with the help of our inbuilt 🔗 Capabilities Generator Tool.
Step 2: Establish User Authentication
Now, you need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the LambdaTest Profile page.
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
- Linux / MacOS
- Windows
export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"
set LT_USERNAME="undefined"
set LT_ACCESS_KEY="undefined"
Step 3: Configure the Necessary Capabilities
To enable the accessibility testing within your automated test suite, set the accessibility: true
in your configuration file. You can also define other settings capabilities as described below.
capability.setCapability("accessibility", true); // Enable accessibility testing
capability.setCapability("accessibility.wcagVersion", "wcag21a"); // Specify WCAG version (e.g., WCAG 2.1 Level A)
capability.setCapability("accessibility.bestPractice", false); // Exclude best practice issues from results
capability.setCapability("accessibility.needsReview", true); // Include issues that need review
Step 4: Execute and Monitor your Test
Now execute your tests and visit the Automation Dashboard. Click on the Accessibility tab and check the report generated.
mvn test