# UiAccessibilityValidator

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiAccessibilityValidator.java+class:androidx.test.uiautomator.UiAccessibilityValidator) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

*** ** * ** ***


```
interface UiAccessibilityValidator
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator#validate(android.view.accessibility.AccessibilityNodeInfo)` method is called by `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice` and `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` before performing any action on a UI element, such as clicking or scrolling. The method is provided with the `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` 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 `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` instance using `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#addUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator#validate(android.view.accessibility.AccessibilityNodeInfo)(node: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html)` Runs a check on the given `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html`. |

## Public functions

### validate

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun validate(node: AccessibilityNodeInfo): Unit
```

Runs a check on the given `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html`.

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: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` | The `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` of the UI element to validate. |