Package com.deque.html.axecore.selenium
Class AxeBuilder
- java.lang.Object
-
- com.deque.html.axecore.selenium.AxeBuilder
-
public class AxeBuilder extends Object
Fluent style builder for invoking aXe. Instantiate a new Builder and configure testing with the include(), exclude(), and options() methods before calling analyze() to run.
-
-
Field Summary
Fields Modifier and Type Field Description StringaxeRunScriptStringsandboxBusterScript
-
Constructor Summary
Constructors Constructor Description AxeBuilder()Initialize an instance of AxeBuilder.AxeBuilder(AxeBuilderOptions builderOptions)Initialize an instance of AxeBuilder.AxeBuilder(AxeBuilderOptions builderOptions, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Initialize an instance of AxeBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resultsanalyze(org.openqa.selenium.WebDriver webDriver)Run axe against the entire page.Resultsanalyze(org.openqa.selenium.WebDriver webDriver, boolean injectAxe)Run axe against the entire page.Resultsanalyze(org.openqa.selenium.WebDriver webDriver, org.openqa.selenium.WebElement... context)Run axe against a specific WebElement or webElements (including its descendants).AxeBuilderdisableRules(List<String> rules)Set the list of rules to skip when running an analysis.AxeBuilderexclude(List<String> selectors)Selectors to exclude in the validation.AxeBuilderOptionsgetDefaultAxeBuilderOptions()get the default axe builder options.StringgetOptions()gets the options.AxeBuilderinclude(List<String> selectors)Selectors to include in the validation.AxeBuildersetAxeScriptProvider(IAxeScriptProvider axeProvider)sets the where we get the axe script from.voidsetOptions(String newOptions)sets the options.AxeBuildersetTimeout(int newTimeout)sets the timeout.AxeBuilderwithOnlyRules(List<String> rules)Limit analysis to only the specified rules.AxeBuilderwithOptions(AxeRunOptions newRunOptions)Run configuration data that is passed to axe for scanning the web page.AxeBuilderwithoutIframeSandboxes()Remove the "sandbox" attribute from iframes on the page.AxeBuilderwithOutputFile(String path)Causes analyze() to write the axe results as a JSON file, in addition to returning it in object format as usual.AxeBuilderwithRules(List<String> rules)Limit analysis to only the specified rules.AxeBuilderwithTags(List<String> tags)Limit analysis to only the specified tags.
-
-
-
Field Detail
-
axeRunScript
public final String axeRunScript
- See Also:
- Constant Field Values
-
sandboxBusterScript
public final String sandboxBusterScript
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AxeBuilder
public AxeBuilder()
Initialize an instance of AxeBuilder.
-
AxeBuilder
public AxeBuilder(AxeBuilderOptions builderOptions)
Initialize an instance of AxeBuilder.- Parameters:
builderOptions- Builder options
-
AxeBuilder
public AxeBuilder(AxeBuilderOptions builderOptions, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Initialize an instance of AxeBuilder.- Parameters:
objectMapper- ObjectMapper to use when doing JSON stuffbuilderOptions- Builder options
-
-
Method Detail
-
getDefaultAxeBuilderOptions
public AxeBuilderOptions getDefaultAxeBuilderOptions()
get the default axe builder options.- Returns:
- the Axe Builder Options
-
setAxeScriptProvider
public AxeBuilder setAxeScriptProvider(IAxeScriptProvider axeProvider)
sets the where we get the axe script from.- Parameters:
axeProvider- the source of the axe script- Returns:
- an Axe Builder object
-
setTimeout
public AxeBuilder setTimeout(int newTimeout)
sets the timeout.- Parameters:
newTimeout- the int value to be set- Returns:
- an Axe Builder object
-
getOptions
public String getOptions()
gets the options.- Returns:
- the options
-
setOptions
public void setOptions(String newOptions)
sets the options.- Parameters:
newOptions- the options to be set
-
withoutIframeSandboxes
public AxeBuilder withoutIframeSandboxes()
Remove the "sandbox" attribute from iframes on the page.- Returns:
- an Axe Builder
-
withOptions
public AxeBuilder withOptions(AxeRunOptions newRunOptions)
Run configuration data that is passed to axe for scanning the web page. This will override the value set by WithRules(string[]), WithTags(string[]) & DisableRules(string[])- Parameters:
newRunOptions- run options to be used for scanning.- Returns:
- an Axe Builder
-
withTags
public AxeBuilder withTags(List<String> tags)
Limit analysis to only the specified tags. Refer https://www.deque.com/axe/axe-for-web/ documentation/api-documentation/#api-name-axegetrules to get the list of supported tag names. Cannot be used with WithRules(string[]) & Options- Parameters:
tags- tags to be used for scanning- Returns:
- an Axe Builder
-
withOnlyRules
public AxeBuilder withOnlyRules(List<String> rules)
Limit analysis to only the specified rules. Refer https://dequeuniversity.com/rules/axe/ to get the complete listing of available rule IDs. Cannot be used with WithTags(List<String>) & Options- Parameters:
rules- rule IDs to be used for scanning- Returns:
- an Axe Builder
-
withRules
public AxeBuilder withRules(List<String> rules)
Limit analysis to only the specified rules. Refer https://dequeuniversity.com/rules/axe/ to get the complete listing of available rule IDs. Cannot be used with WithTags(List<String>) & Options- Parameters:
rules- rule IDs to be used for scanning- Returns:
- an Axe Builder
-
disableRules
public AxeBuilder disableRules(List<String> rules)
Set the list of rules to skip when running an analysis. Refer https://dequeuniversity.com/rules/axe/ to get the complete listing of available rule IDs. Cannot be used with Options- Parameters:
rules- rule IDs to be skipped from analysis- Returns:
- an Axe Builder
-
include
public AxeBuilder include(List<String> selectors)
Selectors to include in the validation. Note that the selectors array uniquely identifies one element in the page, Valid usage: axeBuilder.Include("#parent-iframe1", "#element-inside-iframe"); to select #element-inside-iframe under #parent-iframe1 axeBuilder.Include("#element-inside-main-frame1"); Invalid usage: axeBuilder.Include("#element-inside-main-frame1", "#element-inside-main-frame2");- Parameters:
selectors- Any valid CSS selectors- Returns:
- an Axe Builder
-
exclude
public AxeBuilder exclude(List<String> selectors)
Selectors to exclude in the validation. Note that the selectors array uniquely identifies one element in the page. Refer include(string[]) for more information on the usage- Parameters:
selectors- Any valid CSS selectors- Returns:
- an Axe Builder
-
withOutputFile
public AxeBuilder withOutputFile(String path)
Causes analyze() to write the axe results as a JSON file, in addition to returning it in object format as usual.- Parameters:
path- Path to the output file. Will be passed as-is to the System.IO APIs.- Returns:
- an Axe builder
-
analyze
public Results analyze(org.openqa.selenium.WebDriver webDriver, org.openqa.selenium.WebElement... context)
Run axe against a specific WebElement or webElements (including its descendants).- Parameters:
webDriver- The webdriver to run axe on.context- WebElement(s) to test- Returns:
- An axe results document
-
analyze
public Results analyze(org.openqa.selenium.WebDriver webDriver)
Run axe against the entire page.- Parameters:
webDriver- The webdriver to run axe on.- Returns:
- An axe results document
-
analyze
public Results analyze(org.openqa.selenium.WebDriver webDriver, boolean injectAxe)
Run axe against the entire page.- Parameters:
webDriver- The webdriver to run axe on.injectAxe- Whether or not to inject axe.- Returns:
- An axe results document
-
-