Reputation: 113
I need to analyze the web driver with wcag2aa
.
I'm using the below dependency.
<dependency>
<groupId>com.deque.html.axe-core</groupId>
<artifactId>selenium</artifactId>
<version>4.2.2</version>
</dependency>
And my accessibility validation method as below.
In this method, result
object doesn't have any violations (violation list is empty) and can see an inapplicable list with wcag2aa
tag values.
Need to know what is wrong with this method.
public void checkAccessibility() {
AxeRunOnlyOptions runOnlyOptions = new AxeRunOnlyOptions();
runOnlyOptions.setType("tag");
runOnlyOptions.setValues(Arrays.asList("wcag2a", "wcag2aa"));
AxeRunOptions options = new AxeRunOptions();
options.setRunOnly(runOnlyOptions);
AxeBuilder axe = new AxeBuilder().withOptions(options);
Results result = axe.analyze(getWebDriver());
List<Rule> violationList = result.getViolations();
System.out.println("Violation list size :"+result.getViolations().size());
System.out.println("Inapplicable list size :"+result.getInapplicable().size());
}
Can anyone help me why the violation list became empty even the page has wcag2aa
violations?
Upvotes: 0
Views: 1241
Reputation: 1417
As per my understanding the result.getViolations()
and result.getInapplicable()
are two different things and both yield a different result.
It might happened that the violation is not present but there are some rules for which no matching elements were found on the page.
Results Object The callback function passed in as the third parameter of axe.run runs on the results object.
This object has four components – a passes array, a violations array, an incomplete array and an inapplicable array.
1) The passes array keeps track of all the passed tests, along with detailed information on each one. This leads to more efficient testing, especially when used in conjunction with manual testing, as the user can easily find out what tests have already been passed.
result.getPasses()
2) The violations array keeps track of all the failed tests, along with detailed information on each one.
result.getViolations()
3) The incomplete array (also referred to as the "review items") indicates which nodes could neither be determined to definitively pass or definitively fail. They are separated out in order that a user interface can display these to the user for manual review (hence the term "review items").
result.getIncomplete()
4) The inapplicable array lists all the rules for which no matching elements were found on the page.
result.getInapplicable()
Ref: https://www.deque.com/axe/core-documentation/api-documentation/
Upvotes: 2