Note If you are using version 2.1.4 and below, refer readme
This project uses HTML CodeSniffer and Deque Axe
HTML CodeSniffer : checks HTML source code and detects any Accessibility violations. Comes with standards that cover the three (A, AA & AAA) conformance levels of the W3C's Web Content Accessibility Guidelines (WCAG) 2.1 and the U.S. Section 508 legislation.
Deque Axe : World’s leading digital accessibility toolkit. Powerful and accurate accessibility toolkit can get you to 80% issue coverage, or more, during development.
- Simple & Easy to use
- No need of prior knowledge on Accessibility
- Works with Java Selenium Webdriver
- Rich Reporting
- Open source
For maven based project add the below dependency
<dependency>
<groupId>io.github.sridharbandi</groupId>
<artifactId>java-a11y</artifactId>
<version>3.0.1</version>
</dependency>
For gradle based project add the below dependency
compile 'io.github.sridharbandi:java-a11y:3.0.1'
For non gradle/maven project download the jar from below mentioned link and add it to CLASSPATH for your project
https://github.com/sridharbandi/Java-a11y/releases
Create object of HtmlCsRunner
as below. driver
will be your WebDriver instance.
HtmlCsRunner htmlCsRunner = new HtmlCsRunner(driver);;
Once after you navigated to any page/popup with Selenium Webdriver execute Accessibility on that particular page/popup
htmlCsRunner.execute();
The above execute
will also generate JSON Report
on accessibility issues at page/popup level
Once after all the tests executed, you can call the below method to generate consolidated HTML Report
on accessibility issues
htmlCsRunner.generateHtmlReport();
Below is junit example with reporting.
import freemarker.template.TemplateException;
import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.sridharbandi.HtmlCsRunner;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.Duration;
/**
* A sample test to demonstrate
*/
public class Example {
private WebDriver driver;
private static HtmlCsRunner htmlCsRunner;
@BeforeEach
public void beforeTest() {
ChromeDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(60));
driver.manage().window().fullscreen();
htmlCsRunner = new HtmlCsRunner(driver);
}
@AfterEach
public void tearDown() throws TemplateException, IOException, URISyntaxException {
htmlCsRunner.execute();
driver.quit();
}
@AfterAll
public static void generateReport() throws IOException {
htmlCsRunner.generateHtmlReport();
}
@Test
public void googleTest() {
driver.get("https://www.google.com/");
}
@Test
public void stockTest() {
driver.get("https://www.istockphoto.com/");
}
}
By default, it will check against WCAG2AA
standards. However, you can configure it to standard you want to test with
htmlCsRunner.setStandard(HTMLCS.WCAG2A);
HTML Reports will be generated under ./target/java-a11y/htmlcs
folder.
Below are the report screenshots
Consolidated Report
Page Report
Create object of AxeRunner
as below. driver
will be your WebDriver instance.
AxeRunner axeRunner = new AxeRunner(driver);;
Once after you navigated to any page/popup with Selenium Webdriver execute Accessibility on that particular page/popup
axeRunner.execute();
The above execute
will also generate JSON Report
on accessibility issues at page/popup level
Once after all the tests executed, you can call the below method to generate consolidated HTML Report
on accessibility issues
axeRunner.generateHtmlReport();
Below is junit example with reporting.
import freemarker.template.TemplateException;
import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.sridharbandi.AxeRunner;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.Duration;
/**
* A sample test to demonstrate
*/
public class Example {
private WebDriver driver;
private static AxeRunner axeRunner;
@BeforeEach
public void beforeTest() {
ChromeDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(60));
driver.manage().window().fullscreen();
axeRunner = new AxeRunner(driver);
}
@AfterEach
public void tearDown() throws TemplateException, IOException, URISyntaxException {
axeRunner.execute();
driver.quit();
}
@AfterAll
public static void generateReport() throws IOException {
axeRunner.generateHtmlReport();
}
@Test
public void googleTest() {
driver.get("https://www.google.com/");
}
@Test
public void stockTest() {
driver.get("https://www.istockphoto.com/");
}
}
HTML Reports will be generated under ./target/java-a11y/axe
folder.
Below are the report screenshots
Consolidated Report
Page Report