Class AccessibilityHelper.AccessibilityResult

java.lang.Object
com.shaft.validation.accessibility.AccessibilityHelper.AccessibilityResult
Enclosing class:
AccessibilityHelper

public static class AccessibilityHelper.AccessibilityResult extends Object
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 Details

    • AccessibilityResult

      public AccessibilityResult()
      Creates a new empty AccessibilityResult. Instances are normally produced by AccessibilityHelper and 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 of 100.0 means no violations were detected.

      Returns:
      accessibility score percentage; 0.0 when no checks were run
    • getPageName

      public String getPageName()
      Returns the page name supplied when the scan was initiated.
      Returns:
      page label; never null
    • setPageName

      public AccessibilityHelper.AccessibilityResult setPageName(String pageName)
      Sets the page name for this result.
      Parameters:
      pageName - human-readable label for the scanned page
      Returns:
      this instance for method chaining
    • getViolations

      public List<com.deque.html.axecore.results.Rule> getViolations()
      Returns the list of axe Rule objects representing detected violations.
      Returns:
      list of violations; may be null if not yet populated
    • setViolations

      public AccessibilityHelper.AccessibilityResult setViolations(List<com.deque.html.axecore.results.Rule> violations)
      Sets the violations list and synchronises violationsCount accordingly.
      Parameters:
      violations - list of axe Rule violations; may be null
      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

      public AccessibilityHelper.AccessibilityResult setViolationsCount(int violationsCount)
      Explicitly sets the violations count. Prefer setViolations(List) which derives this value automatically from the list size.
      Parameters:
      violationsCount - non-negative count of violations
      Returns:
      this instance for method chaining
    • setPassesCount

      public AccessibilityHelper.AccessibilityResult setPassesCount(int passCount)
      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

      public AccessibilityHelper.AccessibilityResult setScore(double score)
      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

      public List<com.deque.html.axecore.results.Rule> getPasses()
      Returns the list of axe Rule objects that the page passed.
      Returns:
      list of passing rules; may be null if 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 axe Rule objects that passed; may be null
      Returns:
      this instance for method chaining
    • getPassCount

      public int getPassCount()
      Returns the number of axe rules the page passed. If the passes list has been populated it is derived from that list; otherwise the count stored by setPassesCount(int) is returned.
      Returns:
      non-negative pass count
    • getTimestamp

      public String getTimestamp()
      Returns the ISO-8601 timestamp captured when the scan completed.
      Returns:
      timestamp string (e.g. "2024-06-01T14:30:00.123456789"); may be null if not yet set
    • setTimestamp

      public AccessibilityHelper.AccessibilityResult setTimestamp(String timestamp)
      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()
      Returns true when at least one WCAG violation was detected.
      assertFalse(result.hasViolations(), "Page should be violation-free");
      
      Returns:
      true if getViolationsCount() > 0
    • toString

      public String toString()
      Overrides:
      toString in class Object