Ignore Rules
You can choose to ignore specified rules while testing accessibility. We support ignoring all instances of a specific rule by name and ignoring some or all rules by View ID. While we feel that all rules are essential, these customizations will let you ignore views that have yet to be fixed and focus on identifying new issues.
In the below examples, axe
refers to the AxeDevTools
object initialized when logging in.
APIs Available
To ignore a specific rule or set of rules, update the configuration before testing takes place.
Ignore Rule(s)
The below code shows how to ignore a specific rule, TouchSizeWcag
.
axe.ignoreRules(mutableListOf("TouchSizeWcag"))
Ignore Some Rules by View ID
A set of rules that will be ignored for the assigned view ID.
axe.ignoreByViewId(
R.id.failing_button,
listOf(
ActiveViewName::class.java
)
)
Ignore All Rules by View ID
Ignores all rules for the provided view IDs.
axe.ignoreAllByViewId(listOf(R.id.your_view_id))
Ignore Experimental Rules
Experimental rules are rulesets that are still in testing and development. When ignoreExperimental
is enabled, all results from the experimental rules will have the status of AxeStatus.IGNORED
.
axe.ignoreExperimental()
Reset Ignored Rules
Within your automated test suite, you may want to start a new set of tests and restore all rules. In this case you may clear any ignored rules you've set using the methods above - with the resetIgnoredRules
API.
@Before
fun setup() {
axe.resetIgnoredRules()
}
@Test
fun testButtonOnly() {
axe.ignoreRules(listOf("ScreenTitle"))
...
}
@Test
fun testScreenTitle() {
...
}
Utilizing Compose or XML APIs today?
To streamline the implementation of axe DevTools Mobile for Android we have deprecated the XML and Compose APIs. We encourage you to switch to the layout agnostic APIs for continued support and access to the latest updates. With the layout agnostic APIs you can scan screens with XML layouts, Compose layouts, or both, all with one API call!
If you are still using XML or Compose APIs, you are also able to ignore rules by view or by class name. Ignoring rules in this way is not supported with the layout agnostic APIs.
Ignore Some Rules by View
A set of rules that will be ignored for the provided views.
axe.ignoreByView(
view,
listOf(
CheckBoxName::class.java
)
)
Ignore All Rules by View
Ignores all rules for the provided views.
axe.ignoreAllByView(listOf(view))
Ignore Some Rules by Class Name
A set of rules that will be ignored for the provided class names.
axe.ignoreByClassName(
TextView::class.java,
listOf(
ColorContrast::class.java
)
)
Ignore All Rules by Class Name
Ignores all rules for the provided class names.
axe.ignoreAllByClassName(listOf(TextView::class.java))