Usage
This example shows how to use UserWay Selenium accessibility library to run static analysis on a webpage:
using OpenQA.Selenium.Chrome;
using UserWay.WebAccessibility.Selenium.Model.Config;
namespace UserWay.WebAccessibility.Selenium.Tests;
public class ScenarioTest
{
[Fact]
public void ShouldDoDefaultManualTest()
{
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://google.com");
var analysisConfig = new AnalysisConfigBuilder()
.ExcludeRules(new HashSet<Rule> { Rule.COLOR_CONTRAST, Rule.COLOR_CONTRAST_ENHANCED })
.SwitchOff(false)
.IncludeBestPractices(true)
.IncludeExperimental(false)
.Build();
var auditConfig = new AuditConfigBuilder()
.Driver(driver)
.AnalysisConfig(analysisConfig)
.ElementScreenshots(true)
.SaveReport(true)
.ReportPath("../../../uw-a11y-reports")
.CustomTags(new HashSet<string> { "scenario", "e2e" })
.Strict(false)
.Build();
AccessibilityAuditor.UserWayAnalysis(auditConfig);
driver.Quit();
}
}
By default, UserWay Selenium scans the page for AA violations and neither saves JSON report nor makes screenshots, but you can easily customize its behavior.