Error Handling in WebDriverJS

Link to Error Handling in WebDriverJS copied to clipboard

How to work around common errors seen in axe DevTools for Web WebDriverJS

Version 4.3.0 and above of the axe DevTools for Web integrations use a new technique when calling AxeDevToolsBuilder.analyze() which opens a new window at the end of a run. Many of the issues outlined in this document address common problems with this technique and their potential solutions.

Having an Out-of-date Driver

A common problem is having an out-of-date driver. To fix this issue make sure that your local install of geckodriver or chromedriver is up-to-date.

An example error message for this problem will include a message about switchToWindow.


(node:17566) UnhandledPromiseRejectionWarning: Error: Malformed type for "handle" parameter of command switchToWindow
Expected: string
Actual: undefined

Having Popup blockers enabled

Popup blockers prevent us from opening the new window when calling AxeDevToolsBuilder.analyze(). The default configuration for most automation testing libraries should allow popups. Please make sure that you do not explicitly enable popup blockers which may cause an issue while running the tests.

AxeDevToolsBuilder.setLegacyMode(legacy: boolean)

If for some reason you are unable to run the new AxeDevToolsBuilder.analyze technique without errors, axe provides a new chainable method that allows you to run the legacy version of AxeDevToolsBuilder.analyze. When using this method axe excludes accessibility issues that may occur in cross-domain frames and iframes.


AxeDevToolsBuilder.setLegacyMode is deprecated and will be removed in v5.0. Please report any errors you may have while running AxeDevToolsBuilder.analyze so that they can be fixed before the legacy version is removed.


var AxeDevToolsBuilder = require('@axe-devtools/webdriverjs');
const WebDriver = require('selenium-webdriver');
(async () => {
  const driver = new WebDriver.Builder().forBrowser('chrome').build();
  await driver.get('');
  try {
    const results = await new AxeDevToolsBuilder(driver)
  } catch (err) {
      // do something with the error
  await driver.quit();