Importing and Initializing for WebDriverIO

Link to Importing and Initializing for WebDriverIO copied to clipboard

Importing and initializing the axe DevTools HTML WebDriverIO package (@axe-devtools/webdriverio)

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 to have WebdriverIO downloaded and configured.

Importing and Initializing

Outside of a module, axe DevTools HTML is imported and an instance created with a statement like this:

const { AxeDevToolsWebdriverIO } = require('@axe-devtools/webdriverio');

Importing WebDriverIO will be required as well:

const webdriverio = require('webdriverio');

Within a module, the syntax is slightly different. The statement should look like this:

import { AxeDevToolsWebdriverIO } from '@axe-devtools/webdriverio';

Importing WebdriverIO will be required as well:

import webdriverio from 'webdriverio';

At this point, you'll be able to initialize your webdriver inside your testing function like this:

const client = webdriverio.remote({
  desiredCapabilities: {
    browserName: 'chrome'
  }
});

await client.init();

Then, you can initalize axe DevTools HTML with the webdriver client

const axeDevTools = new AxeDevToolsWebdriverIO({ client });

Next Steps

Once you've installed, imported, and initialized axe DevTools HTML and its driver, you're ready to move on to scanning for accessibility and writing accessibility tests. Each scan with axe DevTools HTML requires a new instance, so to set up and run your scans 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.