axe DevTools for Web Capybara
The axe-devtools-capybara
gem provides a chainable axe API for the Capybara WebDriver and automatically injects it into all frames.
Setup and Usage
Before beginning, ensure you have access to Deque's registry. If not, refer to the setup guide
- Add
axe-devtools-capybara
to your Gemfile or gemspec file and runbundle install
.
gem "axe-devtools-capybara"
spec.add_dependency "axe-devtools-capybara"
- Require the gem and configure as shown below:
require 'axe-devtools-capybara'
# configure `AxeCapybara`
driver = AxeCapybara.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/'
API
AxeCapybara.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 capybara
. The valid browser names are:
:firefox
(default):chrome
:safari
note
Please ensure the necessary drivers (for example, geckodriver
) are installed in 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 |
The configuration block can also take parameters for adavanced AxeDevTools
configuration