Class WCAGContext


  • public class WCAGContext
    extends Object
    Context related to WCAG (accessibility) validation with axe-core.
    Since:
    15.2RC1
    Version:
    $Id: d509c5ade12f1d4c3ea2f83f2533e101851e2fb4 $
    • Constructor Detail

      • WCAGContext

        public WCAGContext()
    • Method Detail

      • setTestClassName

        public void setTestClassName​(String testClassName)
        Sets the current test class name. This name is the string representation of the TestUI class in which the current wcag validation happens.
        Parameters:
        testClassName - the test class name to be set
      • getTestClassName

        protected String getTestClassName()
      • setTestMethodName

        public void setTestMethodName​(String testMethodName)
        Sets the current test method name. This name is the string representation of a Test method in a testUI class in which the current wcag validation happens.
        Parameters:
        testMethodName - the test method name to be set
      • getTestMethodName

        protected String getTestMethodName()
      • getAxeBuilder

        public com.deque.html.axecore.selenium.AxeBuilder getAxeBuilder()
        Instantiate and initialize an axe builder with context options.
        Returns:
        a ready-to-use AxeBuilder instance
      • isNotCached

        public boolean isNotCached​(String url,
                                   String className)
        Parameters:
        url - the URL of the page to analyze
        className - the class of the page to analyze
        Returns:
        true if there's a need to perform an accessibility analysis of a basePage or false otherwise
      • addWCAGResults

        public void addWCAGResults​(String url,
                                   String className,
                                   com.deque.html.axecore.results.Results newViolations)
        Appends WCAG results to the current context.
        Parameters:
        url - the URL of the page analyzed
        className - the class of the page analyzed
        newViolations - append violations found on the page to the passed results object
      • addWCAGTime

        public void addWCAGTime​(long time)
        Parameters:
        time - the amount of time to count up, in ms.
      • getWCAGTime

        public long getWCAGTime()
        Returns:
        the accumulated time spent validating accessibility.
      • getWCAGFailAmount

        public long getWCAGFailAmount()
        Returns:
        the total amount of failing wcag violations.
      • getWCAGWarnAmount

        public long getWCAGWarnAmount()
        Returns:
        the total amount of non failing wcag violations.
      • setWCAGEnabled

        public void setWCAGEnabled​(boolean wcag)
        Parameters:
        wcag - validation enabled setup parameter to use in the test suite.
      • isWCAGEnabled

        public boolean isWCAGEnabled()
        Returns:
        true if WCAG validation is enabled, false otherwise
      • hasWCAGFails

        public boolean hasWCAGFails()
        Returns:
        any of the validations found a failing violation.
      • hasWCAGWarnings

        public boolean hasWCAGWarnings()
        Returns:
        any of the validations found a warning violation.
      • buildFailsReport

        public String buildFailsReport()
        Returns:
        a readable report of WCAG failures found so far.
      • buildWarningsReport

        public String buildWarningsReport()
        Returns:
        a readable report of WCAG violations (non failing) found so far.
      • writeWCAGReportToFile

        public static void writeWCAGReportToFile​(File outputFile,
                                                 String output)
                                          throws IOException
        Writes a WCAG report to a file for proper accessibility warnings and failures examination.
        Parameters:
        outputFile - the file to write the test results to
        output - the test results to write
        Throws:
        IOException