# By

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

*** ** * ** ***


```
public class By
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/test/uiautomator/By` is a utility class which enables the creation of `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`s in a concise manner.

Its primary function is to provide static factory methods for constructing `https://developer.android.com/reference/androidx/test/uiautomator/BySelector`s using a shortened syntax. For example, you would use `findObject(By.text("foo"))` rather than `findObject(new BySelector().text("foo"))` to select UI elements with the text value "foo".

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/test/uiautomator/By.Window` This nested class is used to create a `https://developer.android.com/reference/androidx/test/uiautomator/ByWindowSelector` that matches a window. |

| ### Public methods |
|---|---|
| `static @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/By#checkable(boolean)(boolean isCheckable)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the checkable criteria. |
| `static @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/By#checked(boolean)(boolean isChecked)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the checked criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria. |
| `static @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/By#clazz(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria. |
| `static @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/By#clazz(java.lang.Class)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Class.html clazz)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria. |
| `static @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/By#clickable(boolean)(boolean isClickable)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the clickable criteria. |
| `static @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/By#copy(androidx.test.uiautomator.BySelector)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/test/uiautomator/BySelector original)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and copies the criteria from `original`. |
| `static @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/By#depth(int)(int depth)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the depth criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria. |
| `static @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/By#desc(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html contentDescription)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria. |
| `static @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/By#descContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria. |
| `static @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/By#descEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria. |
| `static @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/By#descStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria. |
| `static @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/By#displayId(int)(int displayId)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the display ID criteria. |
| `static @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/By#enabled(boolean)(boolean isEnabled)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the enabled criteria. |
| `static @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/By#focusable(boolean)(boolean isFocusable)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the focusable criteria. |
| `static @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/By#focused(boolean)(boolean isFocused)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the focused criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds an ancestor selector criteria. |
| `static @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/By#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 )` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds an ancestor selector criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a child selector criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a descendant selector criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a descendant selector criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a parent selector criteria. |
| `static @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/By#hint(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html hint)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria. |
| `static @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/By#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 regex)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria. |
| `static @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/By#hintContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria. |
| `static @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/By#hintEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria. |
| `static @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/By#hintStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria. |
| `static @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/By#longClickable(boolean)(boolean isLongClickable)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the long clickable criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the application package name criteria. |
| `static @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/By#pkg(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html applicationPackage)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the application package name criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource id criteria. |
| `static @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/By#res(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html resourceName)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource name criteria. |
| `static @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/By#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)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource name criteria. |
| `static @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/By#scrollable(boolean)(boolean isScrollable)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the scrollable criteria. |
| `static @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/By#selected(boolean)(boolean isSelected)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the selected criteria. |
| `static @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/By#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 regex)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria. |
| `static @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/By#text(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria. |
| `static @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/By#textContains(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html substring)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria. |
| `static @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/By#textEndsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html suffix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria. |
| `static @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/By#textStartsWith(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html prefix)` Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria. |

## Public methods

### checkable

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the checkable criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#checkable(boolean)` | BySelector.checkable(boolean) |

### checked

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the checked criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#checked(boolean)` | BySelector.checked(boolean) |

### clazz

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.util.regex.Pattern)` | BySelector.clazz(Pattern) |

### clazz

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.String)` | BySelector.clazz(String) |

### clazz

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.Class)` | BySelector.clazz(Class) |

### clazz

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the class name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clazz(java.lang.String,java.lang.String)` | BySelector.clazz(String, String) |

### clickable

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the clickable criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#clickable(boolean)` | BySelector.clickable(boolean) |

### copy

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

```
public static @NonNull BySelector copy(@NonNull BySelector original)
```

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and copies the criteria from `original`.

### depth

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the depth criteria.

### desc

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#desc(java.util.regex.Pattern)` | BySelector.desc(Pattern) |

### desc

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#desc(java.lang.String)` | BySelector.desc(String) |

### descContains

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descContains(java.lang.String)` | BySelector.descContains(String) |

### descEndsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descEndsWith(java.lang.String)` | BySelector.descEndsWith(String) |

### descStartsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the content description criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#descStartsWith(java.lang.String)` | BySelector.descStartsWith(String) |

### displayId

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the display ID criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#displayId(int)` | BySelector.displayId(int) |

### enabled

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the enabled criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#enabled(boolean)` | BySelector.enabled(boolean) |

### focusable

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the focusable criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#focusable(boolean)` | BySelector.focusable(boolean) |

### focused

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the focused criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#focused(boolean)` | BySelector.focused(boolean) |

### hasAncestor

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds an ancestor selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasAncestor(androidx.test.uiautomator.BySelector)` | BySelector.hasAncestor(BySelector) |

### hasAncestor

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds an ancestor selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasAncestor(androidx.test.uiautomator.BySelector,int)` | BySelector.hasAncestor(BySelector, int) |

### hasChild

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a child selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasChild(androidx.test.uiautomator.BySelector)` | BySelector.hasChild(BySelector) |

### hasDescendant

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a descendant selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasDescendant(androidx.test.uiautomator.BySelector)` | BySelector.hasDescendant(BySelector) |

### hasDescendant

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a descendant selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasDescendant(androidx.test.uiautomator.BySelector,int)` | BySelector.hasDescendant(BySelector, int) |

### hasParent

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and adds a parent selector criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hasParent(androidx.test.uiautomator.BySelector)` | BySelector.hasParent(BySelector) |

### hint

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hint(java.lang.String)` | BySelector.hint(String) |

### hint

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hint(java.util.regex.Pattern)` | BySelector.hint(Pattern) |

### hintContains

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintContains(java.lang.String)` | BySelector.hintContains(String) |

### hintEndsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintEndsWith(java.lang.String)` | BySelector.hintEndsWith(String) |

### hintStartsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the hint value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#hintStartsWith(java.lang.String)` | BySelector.hintStartsWith(String) |

### longClickable

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the long clickable criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#longClickable(boolean)` | BySelector.longClickable(boolean) |

### pkg

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the application package name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#pkg(java.util.regex.Pattern)` | BySelector.pkg(Pattern) |

### pkg

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the application package name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#pkg(java.lang.String)` | BySelector.pkg(String) |

### res

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource id criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.util.regex.Pattern)` | BySelector.res(Pattern) |

### res

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.lang.String)` | BySelector.res(String) |

### res

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the resource name criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#res(java.lang.String,java.lang.String)` | BySelector.res(String, String) |

### scrollable

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the scrollable criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#scrollable(boolean)` | BySelector.scrollable(boolean) |

### selected

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the selected criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#selected(boolean)` | BySelector.selected(boolean) |

### text

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

```
public static @NonNull BySelector text(@NonNull Pattern regex)
```

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#text(java.util.regex.Pattern)` | BySelector.text(Pattern) |

### text

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#text(java.lang.String)` | BySelector.text(String) |

### textContains

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textContains(java.lang.String)` | BySelector.textContains(String) |

### textEndsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textEndsWith(java.lang.String)` | BySelector.textEndsWith(String) |

### textStartsWith

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

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

Constructs a new `https://developer.android.com/reference/androidx/test/uiautomator/BySelector` and sets the text value criteria.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/BySelector#textStartsWith(java.lang.String)` | BySelector.textStartsWith(String) |