Follow

Access Continuum APIs

Overview

Access Engine exposes a number of API functions, detailed below, for both Java and JavaScript. These API functions can be used to test various development artifacts, from nodes to pages, for accessibility within existing development processes.

Note that we have optimized the JavaScript in Access Engine and the entire testing process to ensure that these tests have negligible impact on performance, and Level Access runs these tests in our own continuous testing process. 

Continuum for Java

Getting Started

To begin, you must create a new instance of the Continuum class:


    com.levelaccess.bdd.continuum.Continuum continuum = new com.levelaccess.bdd.continuum.Continuum();
    

Next, invoke the setUp method of your new instance of Continuum using an instance of Selenium WebDriver for the browser of your choice (read more about initializing WebDriver with Selenium), similar to the following example: 


    org.openqa.selenium.WebDriver driver = new org.openqa.selenium.chrome.ChromeDriver();
    continuum.setUp(driver);
    

Optionally, we recommend using an existing Java library to manage your web drivers, such as the following WebDriver Manager: https://github.com/bonigarcia/webdrivermanager. Using a WebDriver Manager will ensure that the latest version is always downloaded automatically at runtime, if necessary. 

The same instance of WebDriver and Continuum can be reused across multiple tests to cut down on initialization time. If for some reason you need to switch out drivers, remember to invoke Continuum's setUp method again, passing in the new driver.

Testing

Once Continuum is initialized, you can use Selenium however you'd like, e.g. by using the driver you created to navigate to a particular URL that you'd like to test for accessibility:


    driver.get("http://www.google.com");
    

Once you've navigated to the page you'd like to test, invoke the appropriate Continuum method, all of which executes synchronously. For example, to run all available accessibility tests against the entirety of the current page:


    List<com.levelaccess.bdd.continuum.AccessibilityConcern> accessibilityConcerns = continuum.runAllTests();
    

You can then do whatever you like with any accessibility concerns returned, like print them out to the console, filter them for only the ones you're interested in, etc. Review our documentation for the AccessibilityConcern class for a complete list of what's returned for each accessibility concern.

Other Continuum methods are available that allow you to only run particular tests or test against specific best practices. Continuum also allows you to only test a particular part of a page rather than the entire page. All of these methods are detailed in our documentation for the Continuum class.

Java APIs

The Continuum for Java APIs are detailed below. For each method, the list of parameters that can be passed is listed.

  • getAccessibilityConcerns()
    Gets the list of accessibility concerns found by Access Engine during the last test execution.

  • getAccessibilityConcernsPrettyPrinted()
    Gets a pretty-printed String of accessibility concerns found by Access Engine during the last test execution.

  • runAllTests()
    Runs all automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). Note: This method, and other Continuum methods for running tests, does not run guided automatic tests. Only fully automatic tests are run.

  • runAllTestsOnNode(String selectorForNodeToTest)
    Runs all automatic Access Engine tests against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext) and the specified CSS (if testing a website) or Appium XPath selector (if testing a mobile app).

  • runTests(Integer[] engineTestIds)
    Runs only the specified automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext) and, for specific test IDs, AMP.

  • runTestsOnNode(Integer[] accessEngineTestIds, String selectorForNodeToTest)
    Runs only the specified automatic Access Engine tests against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext) and, for specific test IDs, AMP.

  • setUp(org.openqa.selenium.WebDriver webDriver)
    Sets up Continuum for web testing.

  • setUp(org.openqa.selenium.WebDriver webDriver, Continuum.TestContext context)
    Sets up Continuum for web or mobile testing.

  • testForBestPractices(Integer[] bestPracticeIds)
    Runs only the automatic Access Engine tests corresponding to the specified best practices against the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext) and, for specific best practice IDs, AMP.

  • testNodeForBestPractices(Integer[] bestPracticeIds, String selectorForNodeToTest)
    Runs only the automatic Access Engine tests corresponding to the specified best practices against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext) and, for specific best practice IDs, AMP.

Read the Continuum Javadocs to learn more about the Continuum for Java API.

Deprecated Methods

The following methods were deprecated with the Continuum 2.3 release on August 8, 2018:

 

getA11yResults()

Renamed for clarity; use getAccessibilityConcerns() instead

 

getA11yResultsPrettyPrinted()

Renamed for clarity; usegetAccessibilityConcernsPrettyPrinted()instead

 

runAllTests_returnInstances_JSON_NodeCapture(String selectorForNode)

Renamed for clarity; userunAllTestsOnNode(String)instead

 

runAllTests_returnInstances_JSON()

Renamed for clarity; userunAllTests()instead

 

setUp(org.openqa.selenium.WebDriver webDriver, String path)

The path to the Access Engine JavaScript file is now automatically inferred without having to specify it. Use one of the other setUp methods instead, i.e. either setUp(WebDriver) or setUp(WebDriver, TestContext)

Continuum for JavaScript

Getting Started

There are two ways of using Continuum for JavaScript based on your testing framework. If you're using server-side JavaScript via something like Node, you'll need to initialize Continuum differently than you would for client-side JavaScript via something like Karma, where the latter necessitates that Continuum be injected directly into the pages to be tested in a web browser. Choose the method that is most appropriate for your testing framework based on the instructions for each below.

Server-side

  1. Import Continuum and invoke its setUp method:
    const continuum = require('../js/Continuum.js').Continuum;
    continuum.setUp(driver, "../js/AccessEngine.community.js");
  2. Set the first parameter to the instance of Selenium WebDriver to use for testing.
  3. Set the second parameter to the relative path from the current JavaScript file to the Access Engine JavaScript file that's included with Continuum for JavaScript. For more information, refer to our documentation for the setUp method.

The same instance of Continuum is meant to be reused across multiple tests. If for some reason you need to switch out drivers, remember to invoke Continuum's setUp method again, passing in the new driver.

Client-side

  1. First, make sure your testing framework is configured to inject Continuum into the page to be tested. Exactly what this means differs from technology to technology. For example, for Karma, this involves editing a Karma-specific configuration file and adding the Continuum.js JavaScript file to the list of files to be injected into the page.

    This is an important first step as with client-side JavaScript, Continuum needs to be injected into the page to be tested before it can be used. Once this is done, a new global variable continuum will be exposed to the page. This is the instance of Continuum referenced below.

  2. Invoke the setUp method of Continuum. For example:

    continuum.setUp(null, "../js/AccessEngine.community.js", window);

    Make sure the first parameter is null; this is where you'd pass in a Selenium WebDriver instance, but that's not applicable for client-side JavaScript.

  3. Set the second parameter to the relative path from the current JavaScript file to the Access Engine JavaScript file that's included with Continuum for JavaScript.
  4. Set the third parameter to the Window object containing the Document object of the page to be tested. For more information, refer to our documentation for the setUp method.

The same instance of Continuum is meant to be reused across multiple tests. If you need to switch window contexts, remember to invoke Continuum's setUp method again, passing in the new Window object. You can also use Continuum's setWindowUnderTestmethod to explicitly set Continuum's testing context to a particular nested Window object to leverage Continuum if it's already been injected into a parent window context, e.g. when testing iframes.

Usage

At this point, Continuum is initialized and ready for use. Invoke the appropriate Continuum method (all of which execute asynchronously using Promises). For example, to run all available accessibility tests against the entirety of the current page:

continuum.runAllTests().then(() => {
    const accessibilityConcerns = continuum.getAccessibilityConcerns();
});

You can then do whatever you like with any accessibility violations returned by the testing engine, such as print them out to the console, filter them for only the ones you're interested in, etc. Review our documentation for the AccessibilityConcern class for a complete list of data returned for each accessibility concern.

Other Continuum methods are available that allow you to only run particular tests or test against specific best practices. Continuum also allows you to only test a particular part of a page rather than the entire page. All of these methods are detailed in our documentation for the Continuum class.

JavaScript APIs

  • getAccessibilityConcerns()
    Gets the list of accessibility concerns found by Access Engine during the last test execution.
  • runAllTests()
    Runs all automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Make sure to invoke this Continuum#setUp method before invoking this method.

  • runAllTestsOnNode(targetNodeOrCssSelectorForTargetNode)
    Runs all automatic Access Engine tests against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke Continuum#setUp and the specified node or its CSS selector. Make sure to invoke this Continuum#setUp method before invoking this method.

  • runTests(engineTestIds)
    Runs only the specified automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Make sure to invoke this Continuum#setUp method before invoking this method.
  • runTestsOnNode(engineTestIds,targetNodeOrCssSelectorForTargetNode)
    Runs only the specified automatic Access Engine tests against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke Continuum#setUp and the specified node or its CSS selector. Make sure to invoke this Continuum#setUp method before invoking this method.

  • setUp(webDriver, locationPath, window)
    Sets up Continuum for web testing.

  • setWindowUnderTest(targetWindow)
    Sets the window to test. This can be used to set the testing context to the contents of an iframe element on the page, rather than the page an iframe element appears on.

  • testForBestPractices(bestPracticeIds)
    Runs only the automatic Access Engine tests corresponding to the specified best practices against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Make sure to invoke this Continuum#setUp method before invoking this method.

  • testNodeForBestPractices(bestPracticeIds, targetNodeOrCssSelectorForTargetNode)
    Runs only the automatic Access Engine tests corresponding to the specified best practices against the current page for only the specified node and all its children, as defined by the web driver used previously to invoke Continuum#setUp and the specified node or its CSS selector. Make sure to invoke this Continuum#setUp method before invoking this method.

You can find more details in the API documentation for Continuum for Javascript here.

Deprecated Methods

The following methods are deprecated with the Continuum 2.3 release on August 8, 2018: 

getA11yResults()
Renamed for clarity; use Continuum#getAccessibilityConcerns instead

runAllTests_returnInstances_JSON()
Renamed for clarity; use Continuum#runAllTests instead.

runAllTests_returnInstances_JSON_NodeCapture()
Renamed for clarity; use Continuum#runAllTestsOnNode instead.

Mobile APIs 

Continuum.MobileType[] values()

 

Read more about mobile testing with Access Continuum here

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Level Access Support
www.levelaccess.com | 800.889.9659
© 2005 - 2018 - Level Access All rights reserved.
Privacy | Security | Credits | License