Ignore Rules

Link to Ignore Rules copied to clipboard

You can choose to ignore specified rules while testing accessibility. We support ignoring a specific rule, ignoring rules by class name, and ignoring rules by accessibility identifier. While we feel that all rules are essential, these customizations will let you ignore views that have yet to be fixed and focus more on unknown or new issues.

important

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, EditTextName.

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 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))

Reset Ignored Rules

Automated test may want to start the next test suite with a blank slate. In this case you may clear any ignored rules set by one of the above methods with the resetIgnoredRules API.

@Before  
fun setup() {
    axe.resetIgnoredRules()
}

@Test 
fun testButtonOnly() {
   axe.ignoreRules(listOf("ScreenTitle"))
   ...
}
 
@Test 
fun testScreenTitle() {
   ...
}