UiAccessibilityValidator


interface UiAccessibilityValidator


A validator that runs during test actions to check the accessibility of the UI.

This interface can be implemented to provide custom accessibility checks. The validate method is called by UiDevice and UiObject2 before performing any action on a UI element, such as clicking or scrolling. The method is provided with the AccessibilityNodeInfo of the element that is being interacted with.

Implementations of this interface may throw exceptions if an accessibility issue is found, which will cause the test to fail.

To use a custom validator, set it on the Configurator instance using addUiAccessibilityValidator.

Summary

Public functions

Unit

Runs a check on the given AccessibilityNodeInfo.

Public functions

validate

Added in 2.4.0-alpha07
fun validate(node: AccessibilityNodeInfo): Unit

Runs a check on the given AccessibilityNodeInfo.

This method is called before any action is performed on the UI element represented by the given node. Implementations may check the node for any accessibility issues and throw an exception if any are found.

Parameters
node: AccessibilityNodeInfo

The AccessibilityNodeInfo of the UI element to validate.