Importing and Initializing for WebDriverJS
Importing and initializing the axe DevTools HTML WebDriverJS package (@axe-devtools/webdriverjs)
Once you've installed axe DevTools HTML, you need to import it into your testing setup and initialize the package.
Prerequisites
In order to import and initialize axe DevTools HTML it needs to be installed first. If you haven't yet, read the guide on how to install it from a bundle, from your artifact repository, or from Deque's Agora. You also need a downloaded and configured Selenium WebDriver of your choice.
Importing and Initializing
Outside of a module, axe DevTools HTML is imported and an instance created with a statement like this:
const { AxeDevToolsWebdriverJS } = require('@axe-devtools/webdriverjs');
Importing WebDriverJS will be required as well:
const webdriver = require('selenium-webdriver');
Within a module, the syntax is slightly different. The statement should look like this:
import { AxeDevToolsWebdriverJS } from '@axe-devtools/webdriverjs';
Importing WebDriverJS will be required as well:
import webdriver from 'selenium-webdriver';
Once you've imported axe DevTools HTML, you can initialize the driver. Each scan requires its own instance of axe DevTools HTML, so you'll initialize that while writing tests.
const driver = new WebDriver.Builder().forBrowser('chrome').build();
Next Steps
Once you've installed, imported, and initialized axe DevTools HTML, you're ready to move on to scanning for accessibility and writing accessibility tests. To do that, see the guide on writing tests.
Troubleshooting
If you have trouble with any of the importing or initializing of axe DevTools HTML, contact your Deque representative directly, reach us via our support desk, or send us an email. We'll be happy to help.