Access Engine exposes a number of API functions for both Java and JavaScript. You can use these API functions to test various development artifacts, like nodes or pages, for accessibility within your existing development processes.
We have optimized the JavaScript in Access Engine and in the entire testing process to ensure that these tests have minimal impact on performance.
On this page:
Continuum for Java
Get started
- Create a new instance of the Continuum class:
com.levelaccess.bdd.continuum.Continuum continuum = new com.levelaccess.bdd.continuum.Continuum();
- Invoke the
setUp
method of your new Continuum instance using an instance of Selenium WebDriver for the browser of your choice (learn more about initializing WebDriver with Selenium). For example:org.openqa.selenium.WebDriver driver = new org.openqa.selenium.chrome.ChromeDriver(); continuum.setUp(driver);
- Optional: Use an existing Java library to manage your web drivers. For example, https://github.com/bonigarcia/webdrivermanager. Using a WebDriver Manager ensures that the latest version is automatically downloaded at runtime, if necessary.
You can reuse the same instance of WebDriver and Continuum across multiple tests to cut down on initialization time. If you need to switch out drivers, you must invoke Continuum's setUp
method again, passing in the new driver.
Test
Once you initialize Continuum, you can use Selenium however you want.
For example:
- Use the driver to navigate to a particular URL that you want to test. For example,
driver.get("http://www.google.com");
- Invoke the appropriate Continuum method. All methods execute 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();
- Use your results! You can print them out to the console, filter them for only the ones you're interested in, and more. Learn more about Continuum results.
Other Continuum methods are available that allow you to run particular tests or test against specific best practices. You can also test a particular part of a page rather than the entire page. Learn more about the Continuum class.
Java APIs
The table below details the Continuum for Java APIs.
Call | Response |
---|---|
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. |
getSupportedBestPractices() | Gets a list of Best Practice IDs and their descriptions for the test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
getSupportedStandards() | Gets a list of accessibility standards for the current test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
getSupportedTests() | Gets a list of automatic Access Engine test IDs and their descriptions for the current test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
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, only run fully automatic tests. They do not run guided automatic tests. |
runAllTestsOnNode(String selectorForNodeToTest) |
Runs all automatic Access Engine tests against the current page for 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 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 the specified automatic Access Engine tests against the current page for 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 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 the automatic Access Engine tests corresponding to the specified best practices against the current page for 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. |
testForNoticeability(Integer minNoticeability) |
Runs the automatic Access Engine tests greater than or equal to the specified noticeability score against the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
testForSeverity(Integer minSeverity) |
Runs the automatic Access Engine tests with a severity greater than or equal to the specified severity of the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver,TestContext). |
testForStandards(Integer[] standardIds) |
Runs the automatic Access Engine tests corresponding to the specified accessibility standards against the current page, as defined by the web driver used previously to invoke setup(WebDriver) or setUp(WebDriver, TestContext). |
testForTractability(Integer minTractability) |
Runs the automatic Access Engine tests with a tractability score greater than or equal to the specified tractability against the current page, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
testNodeForBestPractices(Integer[] bestPracticeIds, String selectorForNodeToTest) |
Runs the automatic Access Engine tests corresponding to the specified best practices against the current page for 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. |
testNodeForNoticeability(Integer minNoticeability,String selectorForNodeToTest) |
Runs the automatic Access Engine tests with a noticeability score greater than or equal to the specified noticeability against the current page for the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
testNodeForSeverity(Integer minSeverity, String selectorForNodeToTest) |
Runs the automatic Access Engine tests with a severity greater than or equal to specified severity against the current page for the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
testNodeForStandards(Integer[] standardIds, String selectorForNodeToTest) |
Runs the automatic Access Engine tests corresponding to the specified accessibility standards against the current page for 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 accessibility standard IDs, AMP. |
testNodeForTractability(Integer minTractability, String selectorForNodeToTest) |
Runs the automatic Access Engine tests with a tractability score greater than or equal to the specified tractability on the specified node and all its children, as defined by the web driver used previously to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
Deprecated Methods
The table below details the methods there were deprecated in Continuum 2.3 release on August 8, 2018.
Method | Change |
---|---|
getA11yResults() |
Renamed for clarity. Use getAccessibilityConcerns() instead. |
getA11yResultsPrettyPrinted() |
Renamed for clarity. Use getAccessibilityConcernsPrettyPrinted() instead. |
runAllTests_returnInstances_JSON_NodeCapture(String selectorForNode) |
Renamed for clarity. Use runAllTestsOnNode(String) instead. |
runAllTests_returnInstances_JSON() |
Renamed for clarity. Use runAllTests() 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. For example, setUp(WebDriver) or setUp(WebDriver, TestContext). |
Continuum for JavaScript
Get 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 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
- Import Continuum and invoke its
setUp
method:const continuum = require('../js/Continuum.js').Continuum;
continuum.setUp(driver, "../js/AccessEngine.community.js");
- Set the first parameter to the instance of Selenium WebDriver to use for testing.
- 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. Learn more about the setUp method.
You can reuse the same instance of Continuum across multiple tests. If you need to switch out drivers, you must invoke Continuum's setUp
method again, passing in the new driver.
Client-side
- Configure your testing framework to inject Continuum into the page for testing. Continuum must be injected into the page for testing before you can use it. After you inject Continuum, a new global variable
continuum
will be exposed on the page.- Note that this configuration varies by technology. For example, Karma requires you to edit a Karma-specific configuration file and add the Continuum.js JavaScript file to the list of files to inject into the page.
- 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 it's not applicable for client-side JavaScript.
- 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.
- Set the third parameter to the Window object containing the Document object of the page you want to test. Learn more about the setUp method.
You can reuse the same instance of Continuum across multiple tests. If you need to switch window contexts, you must invoke Continuum's setUp
method again, passing in the new window object. You can also use Continuum's setWindowUnderTest method to set Continuum's testing context to a particular nested Window object if it's already been injected into a parent window context. For example, when testing iframes.
Usage
Once you initialize Continuum, you can invoke the appropriate Continuum method (all of which execute asynchronously using Promises). For example, to run all available accessibility tests against the current page:
continuum.runAllTests().then(() => {
const accessibilityConcerns = continuum.getAccessibilityConcerns();
});
Once you get your results, you can print them out to the console, filter them for only the ones you're interested in, and more. Learn more about Continuum results.
Other Continuum methods are available that allow you to run particular tests or test against specific best practices. You can also test a particular part of a page rather than the entire page. Learn more about the Continuum class.
JavaScript APIs
Call | Response |
---|---|
getAccessibilityConcerns() | Gets the list of accessibility concerns found by Access Engine during the last test execution. |
getSupportedBestPractices() | Gets a list of Best Practice IDs and their descriptions for the test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
getSupportedStandards() | Gets a list of accessibility standards for the current test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
getSupportedTests() | Gets a list of automatic Access Engine test IDs and their descriptions for the current test context and mobile type used to invoke setUp(WebDriver) or setUp(WebDriver, TestContext). |
runAllTests() |
Runs all automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke this Continuum#setUp method before invoking this method. |
runAllTestsOnNode(targetNodeOrCssSelectorForTargetNode) |
Runs all automatic Access Engine tests against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
runTests(engineTestIds) |
Runs the specified automatic Access Engine tests against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke the Continuum#setUp method before invoking this method. |
runTestsOnNode(engineTestIds,targetNodeOrCssSelectorForTargetNode) |
Runs the specified automatic Access Engine tests against the current page for 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. Always invoke the 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 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. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForBestPractices(bestPracticeIds, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests corresponding to the specified best practices against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
testForNoticeability(minNoticeability) |
Runs the automatic Access Engine tests of or greater than the specified noticeability against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke the Continuum#setUp method before invoking this method. |
testForSeverity(minSeverity) |
Runs the automatic Access Engine tests with a severity greater than or equal to the specified severity against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke the Continuum#setUp method before invoking this method. |
testForStandards(standardIDs) |
Runs the automatic Access Engine tests corresponding to the specified accessibility standards against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke the Continuum#setUp method before invoking this method. |
testForTractability(minTractability) |
Runs the automatic Access Engine tests with a tractability score greater than or equal to the specified tractability against the current page, as defined by the web driver used previously to invoke Continuum#setUp. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForBestPractice(bestPracticeIds, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests corresponding to the specified best practices against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForNoticeability(minNoticeability, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests with a noticeability score greater than or equal to the specified noticeability against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForSeverity(minSeverity, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests with a severity greater than or equal to the specified severity against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForStandards(standardIds, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests corresponding to the specified accessibility standards against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
testNodeForTractability(minTractability, targetNodeOrCssSelectorForTargetNode) |
Runs the automatic Access Engine tests with a tractability score greater than or equal to the specified tractability against the current page for 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. Always invoke the Continuum#setUp method before invoking this method. |
Learn more about Continuum for Javascript.
Deprecated Methods
The table below details the methods there were deprecated in the Continuum 2.3 release on August 8, 2018.
Method | Change |
---|---|
getA11yResults() |
Renamed for clarity. Use Continuum#getAccessibilityConcerns |
runAllTests_returnInstances_JSON_NodeCapture() |
Renamed for clarity. Use Continuum#runAllTestsOnNode instead. |
runAllTests_returnInstances_JSON() |
Renamed for clarity. Use Continuum#runAllTests instead. |
Mobile APIs
Continuum.MobileType[] values()
Learn more about mobile testing with Access Continuum.
Comments
0 comments
Article is closed for comments.