Today one person asked me about how to do accessibility tests in Selenium.
I remember after I joined this team, we used Chisel Web Selenium to scan the page directly in Visual Studio. However, we could not know if this test passed or failed locally.
new ChiselWebSelenium().Scan(webdriver, "Scan name");
Once we deployed to DEV/PPE and
ran the tests, some test failures appeared in the Azure release pipeline (in accessibility
tab). Resetting the baseline could ignore the failures.
In September 2019, we were told
that Chisel Web Selenium was deprecated in August 2019 and we needed to move to
Selenium Axe
as soon as possible.
At that time if we used Selenium Axe, all tests failed in Visual Studio directly. Since this is the new model, we need to exclude the known failures.
Here is the good example(TestAccessibilityOfPageExcludingKnownIssues
) to show how we needed to update the code.
AxeResult axeResult = new AxeBuilder(Driver)
.WithOptions(
new AxeRunOptions()
{
RunOnly = new
RunOnlyOptions()
{
Type =
"tag",
Values = new
List<string>() { "wcag21a", "wcag21aa" },
},
Iframes = false,
})
// Exclude some elements
.Exclude("#meInitialsButton")
.Exclude("script#mt_script")
.Analyze();
axeResult.Violations.Should().BeEmpty();
No comments:
Post a Comment