AxeRunOnly Class
Control which accessibility rules are executed during axe Watcher testing
The AxeRunOnly
class allows you to limit which accessibility rules are executed during accessibility testing with axe Watcher. You can specify a set of rules or tags to run, excluding all others from the analysis. This provides a way to focus testing on specific accessibility requirements or concerns.
This class is used in conjunction with AxeRunOptions
to customize the behavior of the axe-core analysis engine.
You cannot use both AxeRunOnly
and accessibilityStandard
(in ConfigurationOverrides
) at the same time.
Constructor
AxeRunOnly()
Creates a new instance of AxeRunOnly
with no settings configured.
AxeRunOnly runOnly = new AxeRunOnly();
Methods
setType(String type)
Sets the type of filtering to apply. Valid values are: "rule", "rules", "tag", or "tags".
Parameters:
type
- String indicating the type of filter. Must be one of: "rule", "rules", "tag", or "tags".
Returns:
AxeRunOnly
- The current instance for method chaining
Throws:
IllegalArgumentException
- If an invalid type is provided
Example:
AxeRunOnly runOnly = new AxeRunOnly();
runOnly.setType("tag");
setValues(List<String> values)
Sets the specific rule IDs or tag names to include in the analysis, based on the type that was set.
Parameters:
values
- List of rule IDs or tag names to include in the analysis
Returns:
AxeRunOnly
- The current instance for method chaining
Example:
AxeRunOnly runOnly = new AxeRunOnly();
runOnly.setType("tag");
runOnly.setValues(Arrays.asList("wcag2a", "wcag2aa"));
getType()
Gets the currently configured filter type.
Returns:
String
- The current filter type ("rule", "rules", "tag", or "tags")
Example:
AxeRunOnly runOnly = new AxeRunOnly();
runOnly.setType("tag");
String type = runOnly.getType(); // Returns "tag"
getValues()
Gets the list of rule IDs or tag names that are configured for inclusion.
Returns:
List<String>
- The list of included rule IDs or tag names
Example:
AxeRunOnly runOnly = new AxeRunOnly();
runOnly.setValues(Arrays.asList("wcag2a", "wcag2aa"));
List<String> values = runOnly.getValues(); // Returns the list of values
toJson()
Serializes the AxeRunOnly
instance to a JSON string.
Returns:
String
- A JSON string representation of the configuration
Example:
AxeRunOnly runOnly = new AxeRunOnly()
.setType("tag")
.setValues(Arrays.asList("wcag2a", "wcag2aa"));
String json = runOnly.toJson();
// Returns: {"type":"tag","values":["wcag2a","wcag2aa"]}
Common Tag Values
Here are some common tag values you can use with the AxeRunOnly
class:
wcag2a
: WCAG 2.0 Level A requirementswcag2aa
: WCAG 2.0 Level AA requirementswcag2aaa
: WCAG 2.0 Level AAA requirementswcag21a
: WCAG 2.1 Level A requirementswcag21aa
: WCAG 2.1 Level AA requirementswcag21aaa
: WCAG 2.1 Level AAA requirementswcag22a
: WCAG 2.2 Level A requirementswcag22aa
: WCAG 2.2 Level AA requirementswcag22aaa
: WCAG 2.2 Level AAA requirementsbest-practice
: Best practice rules that aren't part of a specific standardexperimental
: Experimental rules that are still being developed
See Axe-core Tags for more axe-core tags.