Deque's axe™ is one of the world's leading digital accessibility toolkits. The
axe-core library provided by Deque allows you to inject functionality into your tests in order to scan content and return an
Below is a guide to set up the Sauce Labs integration. This integration allows you to run your accessibility tests, using axe™, on our platform.
a11y stand for, and what is Accessibility Testing?
See the following link for further information.
For the purpose of this guide, we will focus entirely on WebdriverIO
Add the following dependencies to your
axe-corefor Accessibility tests (
sauce-servicefor the WebdriverIO plugin service
Next, create a
wdio.conf.js in your root project directory, see the WebdriverIO documentation for further details.
wdio.conf.js file, create an object called
axeWdio. This object creates a new
AxeWebdriverIO instance which accepts the current browser object from WDIO as an argument.
Next, we need to inject an
axe-core command into the current page so that it scan for content:
analyze() command is called,
axe-core then scans the current document content.
The final step is to define a local variable to store the violations (critical, moderate, and/or minor) and return the
Before you test on Sauce Labs, ensure your axe™ accessibility tests return the desired
a11y results. The best course of action is to test against local drivers such as chrome, firefox, safari, etc.
Here are some examples of how to instantiate a local driver through the
For further information please read the following:
- WebdriverIO Documentation for setting up Driver Binaries
- WebdriverIO Documentation for the config file
Now in your actual tests, all you need to do is call the following to get the
axe-core test results:
It's recommended that you create a separate
.conf.js file in order to manage the Sauce Labs configuration details.
Specify the Sauce Labs
key and data center
region in which you want to run your tests.
You can retrieve your Sauce Labs account credentials with this link. The
region property is used for both Virtual Machine Cloud and Real Device Cloud tests, and the acceptable values are:
Don't Hard-Code Credentials
region property values is not a recommended best practice due to security reasons.
Instead, export your Sauce Labs Account Credentials as Environment Variables and add them in your script like the following example:
Visit the WebDriverIO documentation for further details.
In order to test on Sauce Labs with multiple different browsers and platforms, add the following configuration options in the
Here are some examples:
Browers and OS support on Sauce Labs
For a full list of supported browsers/platforms visit this page.
It's also a best practice to set test options that are specific to Sauce Labs features. For example, declare this at the top of your configuration:
and call it in the
sauce:options test option, as a part of the
capabilities object, like in this example below: