# BySelector

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/BySelector.java+class:androidx.test.uiautomator.BySelector) Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

*** ** * ** ***


```
public class BySelector
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` specifies criteria for matching UI elements during a call to `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice#findObject(androidx.test.uiautomator.BySelector)`.

## Summary

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#checkable(boolean)(boolean isCheckable)` Sets the search criteria to match elements that are checkable or not checkable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#checked(boolean)(boolean isChecked)` Sets the search criteria to match elements that are checked or unchecked. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html className)` Sets the class name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className)` Sets the class name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.Class)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html clazz)` Sets the class name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.String,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html packageName, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className)` Sets the class name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clickable(boolean)(boolean isClickable)` Sets the search criteria to match elements that are clickable or not clickable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#depth(int)(int exactDepth)` Sets the search criteria to match elements that are at a certain depth. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#depth(int,int)(int min, int max)` Sets the search criteria to match elements that are in a range of depths. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#desc(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html contentDescription)` Sets the content description criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#desc(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html contentDescription)` Sets the content description criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Sets the content description criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Sets the content description criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Sets the content description criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 30) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#displayId(int)(int displayId)` Adds a display ID selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#enabled(boolean)(boolean isEnabled)` Sets the search criteria to match elements that are enabled or disabled. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#focusable(boolean)(boolean isFocusable)` Sets the search criteria to match elements that are focusable or not focusable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#focused(boolean)(boolean isFocused)` Sets the search criteria to match elements that are focused or unfocused. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasAncestor(androidx.test.uiautomator.BySelector)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector ancestorSelector)` Adds an ancestor selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasAncestor(androidx.test.uiautomator.BySelector,int)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector ancestorSelector, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int maxAncestorDistance )` Adds an ancestor selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasChild(androidx.test.uiautomator.BySelector)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector childSelector)` Adds a child selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasDescendant(androidx.test.uiautomator.BySelector)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector descendantSelector)` Adds a descendant selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasDescendant(androidx.test.uiautomator.BySelector,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector descendantSelector, int maxDepth)` Adds a descendant selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasParent(androidx.test.uiautomator.BySelector)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector parentSelector)` Adds a parent selector criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hint(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html hintValue)` Sets the hint value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hint(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html hintValue)` Sets the hint value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Sets the hint value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Sets the hint value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Sets the hint value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#longClickable(boolean)(boolean isLongClickable)` Sets the search criteria to match elements that are long clickable or not long clickable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#maxDepth(int)(int max)` Sets the search criteria to match elements that are no more than a certain depth. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#minDepth(int)(int min)` Sets the search criteria to match elements that are at least a certain depth. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#pkg(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html applicationPackage)` Sets the package name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#pkg(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html applicationPackage)` Sets the application package name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html resourceName)` Sets the resource name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourceName)` Sets the resource name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.lang.String,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourcePackage, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourceId)` Sets the resource name criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#scrollable(boolean)(boolean isScrollable)` Sets the search criteria to match elements that are scrollable or not scrollable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#selected(boolean)(boolean isSelected)` Sets the search criteria to match elements that are selected or not selected. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#text(java.util.regex.Pattern)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html textValue)` Sets the text value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#text(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html textValue)` Sets the text value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Sets the text value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Sets the text value criteria for matching. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Sets the text value criteria for matching. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#toString()()` Returns a `https://developer.android.com/reference/java/lang/String.html` representation of this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

## Public methods

### checkable

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

```
public @NonNull BySelector checkable(boolean isCheckable)
```

Sets the search criteria to match elements that are checkable or not checkable.

| Parameters |
|---|---|
| `boolean isCheckable` | Whether to match elements that are checkable or elements that are not checkable. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### checked

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

```
public @NonNull BySelector checked(boolean isChecked)
```

Sets the search criteria to match elements that are checked or unchecked.

| Parameters |
|---|---|
| `boolean isChecked` | Whether to match elements that are checked or elements that are unchecked. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### clazz

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

```
public @NonNull BySelector clazz(@NonNull Pattern className)
```

Sets the class name criteria for matching. A UI element will be considered a match if its full class name matches the `className``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html className` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### clazz

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

```
public @NonNull BySelector clazz(@NonNull String className)
```

Sets the class name criteria for matching. A UI element will be considered a match if its class name exactly matches the `className` parameter and all other criteria for this selector are met. If `className` starts with a period, it is assumed to be in the `https://developer.android.com/reference/android/widget/package-summary.html` package.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The full class name value to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### clazz

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

```
public @NonNull BySelector clazz(@NonNull Class clazz)
```

Sets the class name criteria for matching. A UI element will be considered a match if its class name matches `clazz` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html clazz` | The class to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` |

### clazz

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

```
public @NonNull BySelector clazz(@NonNull String packageName, @NonNull String className)
```

Sets the class name criteria for matching. A UI element will be considered a match if its package and class name exactly match the `packageName` and `className` parameters and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html packageName` | The package value to match. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class name value to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### clickable

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

```
public @NonNull BySelector clickable(boolean isClickable)
```

Sets the search criteria to match elements that are clickable or not clickable.

| Parameters |
|---|---|
| `boolean isClickable` | Whether to match elements that are clickable or elements that are not clickable. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### depth

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

```
public @NonNull BySelector depth(int exactDepth)
```

Sets the search criteria to match elements that are at a certain depth.

### depth

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

```
public @NonNull BySelector depth(int min, int max)
```

Sets the search criteria to match elements that are in a range of depths.

### desc

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

```
public @NonNull BySelector desc(@NonNull Pattern contentDescription)
```

Sets the content description criteria for matching. A UI element will be considered a match if its content description matches the `contentDescription``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html contentDescription` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### desc

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

```
public @NonNull BySelector desc(@NonNull String contentDescription)
```

Sets the content description criteria for matching. A UI element will be considered a match if its content description exactly matches the `contentDescription` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html contentDescription` | The exact value to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### descContains

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

```
public @NonNull BySelector descContains(@NonNull String substring)
```

Sets the content description criteria for matching. A UI element will be considered a match if its content description contains the `substring` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring` | The substring to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### descEndsWith

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

```
public @NonNull BySelector descEndsWith(@NonNull String suffix)
```

Sets the content description criteria for matching. A UI element will be considered a match if its content description ends with the `suffix` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix` | The suffix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### descStartsWith

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

```
public @NonNull BySelector descStartsWith(@NonNull String prefix)
```

Sets the content description criteria for matching. A UI element will be considered a match if its content description starts with the `prefix` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix` | The prefix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### displayId

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

```
@RequiresApi(value = 30)
public @NonNull BySelector displayId(int displayId)
```

Adds a display ID selector criteria for matching. A UI element will be considered a match if it is within the display with the ID of `displayId` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `int displayId` | The display ID to match. Use getDisplayId to get the ID. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### enabled

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

```
public @NonNull BySelector enabled(boolean isEnabled)
```

Sets the search criteria to match elements that are enabled or disabled.

| Parameters |
|---|---|
| `boolean isEnabled` | Whether to match elements that are enabled or elements that are disabled. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### focusable

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

```
public @NonNull BySelector focusable(boolean isFocusable)
```

Sets the search criteria to match elements that are focusable or not focusable.

| Parameters |
|---|---|
| `boolean isFocusable` | Whether to match elements that are focusable or elements that are not focusable. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### focused

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

```
public @NonNull BySelector focused(boolean isFocused)
```

Sets the search criteria to match elements that are focused or unfocused.

| Parameters |
|---|---|
| `boolean isFocused` | Whether to match elements that are focused or elements that are unfocused. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hasAncestor

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

```
public @NonNull BySelector hasAncestor(@NonNull BySelector ancestorSelector)
```

Adds an ancestor selector criteria for matching. A UI element will be considered a match if it has an ancestor element which matches the `ancestorSelector` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector ancestorSelector` | The selector used to find a matching ancestor element. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hasAncestor

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

```
public @NonNull BySelector hasAncestor(
    @NonNull BySelector ancestorSelector,
    @IntRange(from = 1) int maxAncestorDistance
)
```

Adds an ancestor selector criteria for matching. A UI element will be considered a match if it has an ancestor element which matches the `ancestorSelector` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector ancestorSelector` | The selector used to find a matching ancestor element. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int maxAncestorDistance` | The maximum distance between the element and its relevant ancestor in the view hierarchy, e.g. 1 only matches the parent element, 2 matches parent or grandparent. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hasChild

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

```
public @NonNull BySelector hasChild(@NonNull BySelector childSelector)
```

Adds a child selector criteria for matching. A UI element will be considered a match if it has a child element (direct descendant) which matches the `childSelector` and all other criteria for this selector are met. If specified more than once, matches must be found for all `childSelector`s.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector childSelector` | The selector used to find a matching child element. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the selector has a parent/ancestor selector |

### hasDescendant

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

```
public @NonNull BySelector hasDescendant(@NonNull BySelector descendantSelector)
```

Adds a descendant selector criteria for matching. A UI element will be considered a match if it has a descendant element which matches the `descendantSelector` and all other criteria for this selector are met. If specified more than once, matches must be found for all `descendantSelector`s.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector descendantSelector` | The selector used to find a matching descendant element. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the selector has a parent/ancestor selector |

### hasDescendant

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

```
public @NonNull BySelector hasDescendant(@NonNull BySelector descendantSelector, int maxDepth)
```

Adds a descendant selector criteria for matching. A UI element will be considered a match if it has a descendant element which matches the `descendantSelector` and all other criteria for this selector are met. If specified more than once, matches must be found for all `descendantSelector`s.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector descendantSelector` | The selector used to find a matching descendant element. |
| `int maxDepth` | The maximum depth under the element to search the descendant. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the selector has a parent/ancestor selector |

### hasParent

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

```
public @NonNull BySelector hasParent(@NonNull BySelector parentSelector)
```

Adds a parent selector criteria for matching. A UI element will be considered a match if it has a parent element (direct ancestor) which matches the `parentSelector` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector parentSelector` | The selector used to find a matching parent element. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hint

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

```
@RequiresApi(value = 26)
public @NonNull BySelector hint(@NonNull Pattern hintValue)
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value matches the `hintValue``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

Hint text is displayed when there's no user input text.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html hintValue` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hint

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

```
@RequiresApi(value = 26)
public @NonNull BySelector hint(@NonNull String hintValue)
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value exactly matches the `hintValue` parameter and all other criteria for this selector are met.

Hint text is displayed when there's no user input text.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html hintValue` | The exact value to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hintContains

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

```
@RequiresApi(value = 26)
public @NonNull BySelector hintContains(@NonNull String substring)
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value contains the `substring` parameter and all other criteria for this selector are met.

Hint text is displayed when there's no user input text.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring` | The substring to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hintEndsWith

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

```
@RequiresApi(value = 26)
public @NonNull BySelector hintEndsWith(@NonNull String suffix)
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value ends with the `suffix` parameter and all other criteria for this selector are met.

Hint text is displayed when there's no user input text.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix` | The suffix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### hintStartsWith

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

```
@RequiresApi(value = 26)
public @NonNull BySelector hintStartsWith(@NonNull String prefix)
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value starts with the `prefix` parameter and all other criteria for this selector are met.

Hint text is displayed when there's no user input text.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix` | The prefix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### longClickable

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

```
public @NonNull BySelector longClickable(boolean isLongClickable)
```

Sets the search criteria to match elements that are long clickable or not long clickable.

| Parameters |
|---|---|
| `boolean isLongClickable` | Whether to match elements that are long clickable or elements that are not long clickable. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### maxDepth

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

```
public @NonNull BySelector maxDepth(int max)
```

Sets the search criteria to match elements that are no more than a certain depth.

### minDepth

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

```
public @NonNull BySelector minDepth(int min)
```

Sets the search criteria to match elements that are at least a certain depth.

### pkg

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

```
public @NonNull BySelector pkg(@NonNull Pattern applicationPackage)
```

Sets the package name criteria for matching. A UI element will be considered a match if its application package name matches the `applicationPackage``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html applicationPackage` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### pkg

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

```
public @NonNull BySelector pkg(@NonNull String applicationPackage)
```

Sets the application package name criteria for matching. A UI element will be considered a match if its application package name exactly matches the `applicationPackage` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html applicationPackage` | The exact value to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### res

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

```
public @NonNull BySelector res(@NonNull Pattern resourceName)
```

Sets the resource name criteria for matching. A UI element will be considered a match if its resource name matches the `resourceName``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html resourceName` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### res

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

```
public @NonNull BySelector res(@NonNull String resourceName)
```

Sets the resource name criteria for matching. A UI element will be considered a match if its resource name exactly matches the `resourceName` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourceName` | The exact value to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### res

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

```
public @NonNull BySelector res(@NonNull String resourcePackage, @NonNull String resourceId)
```

Sets the resource name criteria for matching. A UI element will be considered a match if its resource package and resource id exactly match the `resourcePackage` and `resourceId` parameters and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourcePackage` | The resource package value to match. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourceId` | The resouce-id value to match. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### scrollable

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

```
public @NonNull BySelector scrollable(boolean isScrollable)
```

Sets the search criteria to match elements that are scrollable or not scrollable.

| Parameters |
|---|---|
| `boolean isScrollable` | Whether to match elements that are scrollable or elements that are not scrollable. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### selected

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

```
public @NonNull BySelector selected(boolean isSelected)
```

Sets the search criteria to match elements that are selected or not selected.

| Parameters |
|---|---|
| `boolean isSelected` | Whether to match elements that are selected or elements that are not selected. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### text

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

```
public @NonNull BySelector text(@NonNull Pattern textValue)
```

Sets the text value criteria for matching. A UI element will be considered a match if its text value matches the `textValue``https://developer.android.com/reference/java/util/regex/Pattern.html` and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/regex/Pattern.html textValue` | The `https://developer.android.com/reference/java/util/regex/Pattern.html` to be used for matching. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### text

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

```
public @NonNull BySelector text(@NonNull String textValue)
```

Sets the text value criteria for matching. A UI element will be considered a match if its text value exactly matches the `textValue` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html textValue` | The exact value to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### textContains

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

```
public @NonNull BySelector textContains(@NonNull String substring)
```

Sets the text value criteria for matching. A UI element will be considered a match if its text value contains the `substring` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring` | The substring to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### textEndsWith

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

```
public @NonNull BySelector textEndsWith(@NonNull String suffix)
```

Sets the text value criteria for matching. A UI element will be considered a match if its text value ends with the `suffix` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix` | The suffix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### textStartsWith

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

```
public @NonNull BySelector textStartsWith(@NonNull String prefix)
```

Sets the text value criteria for matching. A UI element will be considered a match if its text value starts with the `prefix` parameter and all other criteria for this selector are met.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix` | The prefix to match (case-sensitive). |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector` | A reference to this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. |

### toString

```
public String toString()
```

Returns a `https://developer.android.com/reference/java/lang/String.html` representation of this `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`. The format is "BySelector \[=' ... \]". Each criteria is listed as a key-value pair where the key is the name of the criteria expressed in all caps (e.g. CLAZZ, RES, etc).