Class AccessibilityHelper.AccessibilityResult
java.lang.Object
com.shaft.validation.accessibility.AccessibilityHelper.AccessibilityResult
- Enclosing class:
AccessibilityHelper
Value object returned by
AccessibilityHelper.analyzePageAccessibilityAndSave(WebDriver, String, boolean)
and its overloads, carrying the aggregated outcome of a single axe accessibility scan.
Instances are constructed internally by AccessibilityHelper and exposed
to test code for programmatic assertions:
AccessibilityResult result =
AccessibilityHelper.analyzePageAccessibilityAndSave(driver, "Home", true);
assertFalse(result.hasViolations(), "Expected no WCAG violations");
System.out.printf("Score: %.1f%% – %d violation(s)%n",
result.getAccessibilityScore(), result.getViolationsCount());
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the overall accessibility score as a percentage in the range[0.0, 100.0].Returns the page name supplied when the scan was initiated.intReturns the number of axe rules the page passed.List<com.deque.html.axecore.results.Rule> Returns the list of axeRuleobjects that the page passed.Returns the ISO-8601 timestamp captured when the scan completed.List<com.deque.html.axecore.results.Rule> Returns the list of axeRuleobjects representing detected violations.intReturns the total number of axe violations found during the scan.booleanReturnstruewhen at least one WCAG violation was detected.setPageName(String pageName) Sets the page name for this result.Sets the list of passing axe rules for this result.setPassesCount(int passCount) Sets the number of rules that the scanned page passed.setScore(double score) Sets the pre-computed accessibility score for this result.setTimestamp(String timestamp) Sets the scan timestamp.setViolations(List<com.deque.html.axecore.results.Rule> violations) Sets the violations list and synchronisesviolationsCountaccordingly.setViolationsCount(int violationsCount) Explicitly sets the violations count.toString()
-
Constructor Details
-
AccessibilityResult
public AccessibilityResult()Creates a new emptyAccessibilityResult. Instances are normally produced byAccessibilityHelperand should not be constructed directly in test code.
-
-
Method Details
-
getAccessibilityScore
public double getAccessibilityScore()Returns the overall accessibility score as a percentage in the range[0.0, 100.0].The score is
(passes / (passes + violations)) × 100. A score of100.0means no violations were detected.- Returns:
- accessibility score percentage;
0.0when no checks were run
-
getPageName
Returns the page name supplied when the scan was initiated.- Returns:
- page label; never
null
-
setPageName
Sets the page name for this result.- Parameters:
pageName- human-readable label for the scanned page- Returns:
- this instance for method chaining
-
getViolations
Returns the list of axeRuleobjects representing detected violations.- Returns:
- list of violations; may be
nullif not yet populated
-
setViolations
public AccessibilityHelper.AccessibilityResult setViolations(List<com.deque.html.axecore.results.Rule> violations) Sets the violations list and synchronisesviolationsCountaccordingly.- Parameters:
violations- list of axeRuleviolations; may benull- Returns:
- this instance for method chaining
-
getViolationsCount
public int getViolationsCount()Returns the total number of axe violations found during the scan.- Returns:
- non-negative violation count
-
setViolationsCount
Explicitly sets the violations count. PrefersetViolations(List)which derives this value automatically from the list size.- Parameters:
violationsCount- non-negative count of violations- Returns:
- this instance for method chaining
-
setPassesCount
Sets the number of rules that the scanned page passed.- Parameters:
passCount- non-negative count of passing rules- Returns:
- this instance for method chaining
-
setScore
Sets the pre-computed accessibility score for this result.- Parameters:
score- accessibility score in the range[0.0, 100.0]- Returns:
- this instance for method chaining
-
getPasses
Returns the list of axeRuleobjects that the page passed.- Returns:
- list of passing rules; may be
nullif not yet populated
-
setPasses
public AccessibilityHelper.AccessibilityResult setPasses(List<com.deque.html.axecore.results.Rule> passes) Sets the list of passing axe rules for this result.- Parameters:
passes- list of axeRuleobjects that passed; may benull- Returns:
- this instance for method chaining
-
getPassCount
public int getPassCount()Returns the number of axe rules the page passed. If thepasseslist has been populated it is derived from that list; otherwise the count stored bysetPassesCount(int)is returned.- Returns:
- non-negative pass count
-
getTimestamp
Returns the ISO-8601 timestamp captured when the scan completed.- Returns:
- timestamp string (e.g.
"2024-06-01T14:30:00.123456789"); may benullif not yet set
-
setTimestamp
Sets the scan timestamp.- Parameters:
timestamp- ISO-8601 date-time string representing when the scan completed- Returns:
- this instance for method chaining
-
hasViolations
public boolean hasViolations()Returnstruewhen at least one WCAG violation was detected.assertFalse(result.hasViolations(), "Page should be violation-free");- Returns:
trueifgetViolationsCount()> 0
-
toString
-