# BySelector

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/uiautomator/BySelector "View this page in Java")

<br />

```
class BySelector
```

<br />

*** ** * ** ***

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

## Summary

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

## Public functions

### checkable

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

```
fun checkable(isCheckable: Boolean): BySelector
```

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

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| `isCheckable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are checkable or elements that are not checkable. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### checked

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

```
fun checked(isChecked: Boolean): BySelector
```

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

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| `isChecked: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are checked or elements that are unchecked. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### clazz

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

```
fun clazz(className: Pattern): BySelector
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `className: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### clazz

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

```
fun clazz(className: String): BySelector
```

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[android.widget](https://developer.android.com/reference/android/widget/package-summary.html)package.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|-------------------------------------|
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The full class name value to match. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### clazz

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

```
fun clazz(clazz: Class): BySelector
```

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                                   |
|--------------------------------------------------------------------------------|---------------------|
| `clazz: `[Class](https://developer.android.com/reference/java/lang/Class.html) | The class to match. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) |

### clazz

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

```
fun clazz(packageName: String, className: String): BySelector
```

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                                            |
|--------------------------------------------------------------------------------------------------|--------------------------------|
| `packageName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The package value to match.    |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)   | The class name value to match. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### clickable

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

```
fun clickable(isClickable: Boolean): BySelector
```

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

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| `isClickable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are clickable or elements that are not clickable. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### depth

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

```
fun depth(exactDepth: Int): BySelector
```

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)  

```
fun depth(min: Int, max: Int): BySelector
```

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)  

```
fun desc(contentDescription: Pattern): BySelector
```

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

|                                              Parameters                                               |
|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `contentDescription: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### desc

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

```
fun desc(contentDescription: String): BySelector
```

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                                                |
|---------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `contentDescription: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The exact value to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### descContains

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

```
fun descContains(substring: String): BySelector
```

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                                           |
|------------------------------------------------------------------------------------------------|------------------------------------------|
| `substring: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The substring to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### descEndsWith

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

```
fun descEndsWith(suffix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `suffix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The suffix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### descStartsWith

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

```
fun descStartsWith(prefix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `prefix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The prefix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun displayId(displayId: Int): BySelector
```

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                                        |
|------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `displayId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The display ID to match. Use getDisplayId to get the ID. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### enabled

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

```
fun enabled(isEnabled: Boolean): BySelector
```

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

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| `isEnabled: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are enabled or elements that are disabled. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### focusable

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

```
fun focusable(isFocusable: Boolean): BySelector
```

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

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| `isFocusable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are focusable or elements that are not focusable. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### focused

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

```
fun focused(isFocused: Boolean): BySelector
```

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

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| `isFocused: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are focused or elements that are unfocused. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### hasAncestor

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

```
fun hasAncestor(ancestorSelector: BySelector): BySelector
```

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                                                       |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
| `ancestorSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | The selector used to find a matching ancestor element. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### hasAncestor

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

```
fun hasAncestor(
    ancestorSelector: BySelector,
    maxAncestorDistance: @IntRange(from = 1) Int
): BySelector
```

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                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ancestorSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector)                                                                                   | The selector used to find a matching ancestor element.                                                                                                             |
| `maxAncestorDistance: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | 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                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### hasChild

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

```
fun hasChild(childSelector: BySelector): BySelector
```

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                                                     |
|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| `childSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | The selector used to find a matching child element. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [java.lang.IllegalArgumentException](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)  

```
fun hasDescendant(descendantSelector: BySelector): BySelector
```

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                                                        |
|-------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `descendantSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | The selector used to find a matching descendant element. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [java.lang.IllegalArgumentException](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)  

```
fun hasDescendant(descendantSelector: BySelector, maxDepth: Int): BySelector
```

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                                                        |
|-------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `descendantSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | The selector used to find a matching descendant element.      |
| `maxDepth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                 | The maximum depth under the element to search the descendant. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [java.lang.IllegalArgumentException](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)  

```
fun hasParent(parentSelector: BySelector): BySelector
```

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                                                      |
|---------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `parentSelector: `[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | The selector used to find a matching parent element. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun hint(hintValue: Pattern): BySelector
```

Sets the hint value criteria for matching. A UI element will be considered a match if its hint value matches the`hintValue`[Pattern](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                                          |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `hintValue: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun hint(hintValue: String): BySelector
```

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                                           |
|------------------------------------------------------------------------------------------------|--------------------------------------------|
| `hintValue: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The exact value to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun hintContains(substring: String): BySelector
```

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                                           |
|------------------------------------------------------------------------------------------------|------------------------------------------|
| `substring: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The substring to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun hintEndsWith(suffix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `suffix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The suffix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/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)
fun hintStartsWith(prefix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `prefix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The prefix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### longClickable

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

```
fun longClickable(isLongClickable: Boolean): BySelector
```

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

|                                               Parameters                                               |
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| `isLongClickable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are long clickable or elements that are not long clickable. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### maxDepth

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

```
fun maxDepth(max: Int): BySelector
```

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)  

```
fun minDepth(min: Int): BySelector
```

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)  

```
fun pkg(applicationPackage: Pattern): BySelector
```

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

|                                              Parameters                                               |
|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `applicationPackage: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### pkg

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

```
fun pkg(applicationPackage: String): BySelector
```

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                                                |
|---------------------------------------------------------------------------------------------------------|---------------------------|
| `applicationPackage: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The exact value to match. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### res

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

```
fun res(resourceName: Pattern): BySelector
```

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

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `resourceName: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### res

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

```
fun res(resourceName: String): BySelector
```

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                                             |
|---------------------------------------------------------------------------------------------------|---------------------------|
| `resourceName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The exact value to match. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### res

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

```
fun res(resourcePackage: String, resourceId: String): BySelector
```

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                                              |
|------------------------------------------------------------------------------------------------------|--------------------------------------|
| `resourcePackage: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The resource package value to match. |
| `resourceId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)      | The resouce-id value to match.       |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### scrollable

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

```
fun scrollable(isScrollable: Boolean): BySelector
```

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

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| `isScrollable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are scrollable or elements that are not scrollable. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### selected

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

```
fun selected(isSelected: Boolean): BySelector
```

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

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| `isSelected: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether to match elements that are selected or elements that are not selected. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### text

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

```
fun text(textValue: Pattern): BySelector
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `textValue: `[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html) | The[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)to be used for matching. |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### text

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

```
fun text(textValue: String): BySelector
```

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                                           |
|------------------------------------------------------------------------------------------------|--------------------------------------------|
| `textValue: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The exact value to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### textContains

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

```
fun textContains(substring: String): BySelector
```

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                                           |
|------------------------------------------------------------------------------------------------|------------------------------------------|
| `substring: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The substring to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### textEndsWith

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

```
fun textEndsWith(suffix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `suffix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The suffix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### textStartsWith

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

```
fun textStartsWith(prefix: String): BySelector
```

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                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------|
| `prefix: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The prefix to match (case-sensitive). |

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector). |

### toString

```
fun toString(): String!
```

Returns a[String](https://developer.android.com/reference/java/lang/String.html)representation of this[BySelector](https://developer.android.com/reference/kotlin/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).