axe DevTools Watir

Link to axe DevTools Watir copied to clipboard

The axe-devtools-watir gem provides a chainable axe API for Watir and automatically injects into all frames.

Setup and Usage

Ensure you have access to Deque's registry. If not, refer to the setup documentation.

Follow the steps below to set up the axe-devtools-watir gem:

  • Add axe-devtools-watir to your Gemfile:

    gem "axe-devtools-watir"

    Or add it to your gemspec file:

    spec.add_dependency "axe-devtools-watir"

    Run bundle install to download and install the gem.

  • Require the gem and configure.

require 'axe-watir' # Note that this shouldn't be 'axe-devtools-watir'

# configure `AxeWatir`
driver = AxeWatir.configure(:firefox) do |c|
  # see below for a full list of configurations
  c.jslib_path = "next-version/axe.js"
end

# use the driver configuration instance
driver.page.navigate.to 'https://www.deque.com/'
note

Although the gem is called axe-devtools-watir, it needs to be referred to as axe-watir with require.

API

AxeWatir.configure

The configure method takes one optional argument as a symbol and a configuration block object: configure(*arg, &block)

The optional argument is a browser name for watir. The valid browser names are:

  • :firefox (default)
  • :chrome
  • :safari
  • :internet_explorer
  • :edge
note

Please ensure the necessary drivers (eg: geckodriver) are installed on your machine.

The block configuration object contains the following properties:

Property Type Description
jslib_path (Optional) String Path to a custom axe source
skip_iframes (Optional) Boolean Indicate if frames should be excluded from injecting with axe

Additionally, the configuration block can also take parameters for advanced AxeDevTools configuration