All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.version1.webdriver.AccessibilityBase Maven / Gradle / Ivy

Go to download

A simple Selenium framework offering externalised configuration, a good selection of libraries for supporting test data, simple WebDriver browser binary resolution and an opinionated approach for WebDriver test design.

There is a newer version: 2.0.1
Show newest version
package com.version1.webdriver;

import com.deque.html.axecore.results.Results;
import com.deque.html.axecore.results.Rule;
import com.deque.html.axecore.selenium.AxeBuilder;
import com.deque.html.axecore.selenium.AxeReporter;
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import java.io.IOException;
import java.util.List;

public class AccessibilityBase {
    private static final String reportPath = System.getProperty("user.dir") + "\\src\\test\\java\\reports\\";

    public static void checkAccessibilityViolations(WebDriver webDriver) throws IOException {
        String reportFile = reportPath + "accessibilityReport";
        AxeBuilder builder = new AxeBuilder();
        Results results = builder.analyze(webDriver);
        saveReport(results, reportFile);
    }

    private static void saveReport(Results results, String reportFile) {
        List violations = results.getViolations();
        if (violations.size() == 0) {
            Assert.assertTrue("No violations found", true);
        } else {
            AxeReporter.writeResultsToJsonFile(reportFile, results);
            Assert.assertEquals(0, violations.size());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy