# BySelector

Summary:[Methods](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#)  

# BySelector

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
BySelector
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|---------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.uiautomator.BySelector |

<br />

*** ** * ** ***

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

## Summary

|                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                               ||
|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[checkable](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#checkable(boolean))`(boolean isCheckable) ` Sets the search criteria to match elements that are checkable or not checkable.                                                                                                                                          |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[checked](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#checked(boolean))`(boolean isChecked) ` Sets the search criteria to match elements that are checked or unchecked.                                                                                                                                                      |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[clazz](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#clazz(java.lang.String, java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` packageName, `[String](https://developer.android.com/reference/java/lang/String.html)` className) ` Sets the class name criteria for matching.     |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[clazz](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#clazz(java.lang.Class))`(`[Class](https://developer.android.com/reference/java/lang/Class.html)` clazz) ` Sets the class name criteria for matching.                                                                                                                     |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[clazz](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#clazz(java.util.regex.Pattern))`(`[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)` className) ` Sets the class name criteria for matching.                                                                                               |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[clazz](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#clazz(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` className) ` Sets the class name criteria for matching.                                                                                                              |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[clickable](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#clickable(boolean))`(boolean isClickable) ` Sets the search criteria to match elements that are clickable or not clickable.                                                                                                                                          |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[depth](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#depth(int, int))`(int min, int max) ` Sets the search criteria to match elements that are in a range of depths.                                                                                                                                                          |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[depth](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#depth(int))`(int exactDepth) ` Sets the search criteria to match elements that are at a certain depth.                                                                                                                                                                   |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[desc](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#desc(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` contentDescription) ` Sets the content description criteria for matching.                                                                                              |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[desc](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#desc(java.util.regex.Pattern))`(`[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)` contentDescription) ` Sets the content description criteria for matching.                                                                               |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[descContains](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#descContains(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the content description criteria for matching.                                                                                       |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[descEndsWith](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#descEndsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the content description criteria for matching.                                                                                       |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[descStartsWith](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#descStartsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the content description criteria for matching.                                                                                   |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[enabled](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#enabled(boolean))`(boolean isEnabled) ` Sets the search criteria to match elements that are enabled or disabled.                                                                                                                                                       |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[focusable](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#focusable(boolean))`(boolean isFocusable) ` Sets the search criteria to match elements that are focusable or not focusable.                                                                                                                                          |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[focused](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#focused(boolean))`(boolean isFocused) ` Sets the search criteria to match elements that are focused or unfocused.                                                                                                                                                      |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[hasChild](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#hasChild(android.support.test.uiautomator.BySelector))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` childSelector) ` Adds a child selector criteria for matching.                                             |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[hasDescendant](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#hasDescendant(android.support.test.uiautomator.BySelector))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` descendantSelector) ` Adds a descendant selector criteria for matching.                         |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[hasDescendant](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#hasDescendant(android.support.test.uiautomator.BySelector, int))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` descendantSelector, int maxDepth) ` Adds a descendant selector criteria for matching.      |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[longClickable](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#longClickable(boolean))`(boolean isLongClickable) ` Sets the search criteria to match elements that are long clickable or not long clickable.                                                                                                                    |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[maxDepth](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#maxDepth(int))`(int max) ` Sets the search criteria to match elements that are no more than a certain depth.                                                                                                                                                          |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[minDepth](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#minDepth(int))`(int min) ` Sets the search criteria to match elements that are at least a certain depth.                                                                                                                                                              |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[pkg](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#pkg(java.util.regex.Pattern))`(`[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)` applicationPackage) ` Sets the package name criteria for matching.                                                                                        |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[pkg](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#pkg(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` applicationPackage) ` Sets the application package name criteria for matching.                                                                                           |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[res](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#res(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` resourceName) ` Sets the resource name criteria for matching.                                                                                                            |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[res](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#res(java.lang.String, java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` resourcePackage, `[String](https://developer.android.com/reference/java/lang/String.html)` resourceId) ` Sets the resource name criteria for matching. |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[res](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#res(java.util.regex.Pattern))`(`[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)` resourceName) ` Sets the resource name criteria for matching.                                                                                             |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[scrollable](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#scrollable(boolean))`(boolean isScrollable) ` Sets the search criteria to match elements that are scrollable or not scrollable.                                                                                                                                     |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[selected](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#selected(boolean))`(boolean isSelected) ` Sets the search criteria to match elements that are selected or not selected.                                                                                                                                               |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[text](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#text(java.util.regex.Pattern))`(`[Pattern](https://developer.android.com/reference/java/util/regex/Pattern.html)` textValue) ` Sets the text value criteria for matching.                                                                                                 |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[text](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#text(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` textValue) ` Sets the text value criteria for matching.                                                                                                                |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[textContains](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#textContains(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the text value criteria for matching.                                                                                                |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[textEndsWith](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#textEndsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the text value criteria for matching.                                                                                                |
| ` `[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | ` `[textStartsWith](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#textStartsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` substring) ` Sets the text value criteria for matching.                                                                                            |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                           | ` `[toString](https://developer.android.com/reference/android/support/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/android/support/test/uiautomator/BySelector).                                             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/uiautomator/BySelector#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public methods

### checkable

```
BySelector checkable (boolean isCheckable)
```

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

<br />

|                                                    Parameters                                                     ||
|---------------|----------------------------------------------------------------------------------------------------|
| `isCheckable` | `boolean`: Whether to match elements that are checkable or elements that are not checkable. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### checked

```
BySelector checked (boolean isChecked)
```

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

<br />

|                                                Parameters                                                 ||
|-------------|----------------------------------------------------------------------------------------------|
| `isChecked` | `boolean`: Whether to match elements that are checked or elements that are unchecked. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### clazz

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

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

<br />

|                           Parameters                           ||
|---------------|-------------------------------------------------|
| `packageName` | `String`: The package value to match. <br />    |
| `className`   | `String`: The class name value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### clazz

```
BySelector clazz (Class clazz)
```

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

<br />

|                  Parameters                  ||
|---------|-------------------------------------|
| `clazz` | `Class`: The class to match. <br /> |

|                                                                                                            Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) <br /> |

### clazz

```
BySelector clazz (Pattern className)
```

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

<br />

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

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### clazz

```
BySelector clazz (String className)
```

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

<br />

|                            Parameters                             ||
|-------------|------------------------------------------------------|
| `className` | `String`: The full class name value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### clickable

```
BySelector clickable (boolean isClickable)
```

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

<br />

|                                                    Parameters                                                     ||
|---------------|----------------------------------------------------------------------------------------------------|
| `isClickable` | `boolean`: Whether to match elements that are clickable or elements that are not clickable. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### depth

```
BySelector depth (int min, 
                int max)
```

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

<br />

|     Parameters      ||
|-------|--------------|
| `min` | `int` <br /> |
| `max` | `int` <br /> |

|                                                  Returns                                                  ||
|---------------------------------------------------------------------------------------------------|--------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | <br /> |

### depth

```
BySelector depth (int exactDepth)
```

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

<br />

|         Parameters         ||
|--------------|--------------|
| `exactDepth` | `int` <br /> |

|                                                  Returns                                                  ||
|---------------------------------------------------------------------------------------------------|--------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | <br /> |

### desc

```
BySelector desc (String contentDescription)
```

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

<br />

|                            Parameters                            ||
|----------------------|--------------------------------------------|
| `contentDescription` | `String`: The exact value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### desc

```
BySelector desc (Pattern contentDescription)
```

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.

<br />

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

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### descContains

```
BySelector descContains (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### descEndsWith

```
BySelector descEndsWith (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### descStartsWith

```
BySelector descStartsWith (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### enabled

```
BySelector enabled (boolean isEnabled)
```

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

<br />

|                                                Parameters                                                ||
|-------------|---------------------------------------------------------------------------------------------|
| `isEnabled` | `boolean`: Whether to match elements that are enabled or elements that are disabled. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### focusable

```
BySelector focusable (boolean isFocusable)
```

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

<br />

|                                                    Parameters                                                     ||
|---------------|----------------------------------------------------------------------------------------------------|
| `isFocusable` | `boolean`: Whether to match elements that are focusable or elements that are not focusable. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### focused

```
BySelector focused (boolean isFocused)
```

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

<br />

|                                                Parameters                                                 ||
|-------------|----------------------------------------------------------------------------------------------|
| `isFocused` | `boolean`: Whether to match elements that are focused or elements that are unfocused. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### hasChild

```
BySelector hasChild (BySelector childSelector)
```

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

<br />

|                                        Parameters                                         ||
|-----------------|--------------------------------------------------------------------------|
| `childSelector` | `BySelector`: The selector used to find a matching child element. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### hasDescendant

```
BySelector hasDescendant (BySelector descendantSelector)
```

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

<br />

|                                             Parameters                                              ||
|----------------------|-------------------------------------------------------------------------------|
| `descendantSelector` | `BySelector`: The selector used to find a matching descendant element. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### hasDescendant

```
BySelector hasDescendant (BySelector descendantSelector, 
                int maxDepth)
```

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

<br />

|                                             Parameters                                              ||
|----------------------|-------------------------------------------------------------------------------|
| `descendantSelector` | `BySelector`: The selector used to find a matching descendant element. <br /> |
| `maxDepth`           | `int`: The maximum depth under the element to search the descendant. <br />   |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### longClickable

```
BySelector longClickable (boolean isLongClickable)
```

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

<br />

|                                                           Parameters                                                            ||
|-------------------|--------------------------------------------------------------------------------------------------------------|
| `isLongClickable` | `boolean`: Whether to match elements that are long clickable or elements that are not long clickable. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### maxDepth

```
BySelector maxDepth (int max)
```

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

<br />

|     Parameters      ||
|-------|--------------|
| `max` | `int` <br /> |

|                                                  Returns                                                  ||
|---------------------------------------------------------------------------------------------------|--------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | <br /> |

### minDepth

```
BySelector minDepth (int min)
```

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

<br />

|     Parameters      ||
|-------|--------------|
| `min` | `int` <br /> |

|                                                  Returns                                                  ||
|---------------------------------------------------------------------------------------------------|--------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | <br /> |

### pkg

```
BySelector pkg (Pattern applicationPackage)
```

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

<br />

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

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### pkg

```
BySelector pkg (String applicationPackage)
```

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

<br />

|                            Parameters                            ||
|----------------------|--------------------------------------------|
| `applicationPackage` | `String`: The exact value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### res

```
BySelector res (String resourceName)
```

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

<br />

|                         Parameters                         ||
|----------------|--------------------------------------------|
| `resourceName` | `String`: The exact value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### res

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

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

<br />

|                                Parameters                                ||
|-------------------|-------------------------------------------------------|
| `resourcePackage` | `String`: The resource package value to match. <br /> |
| `resourceId`      | `String`: The resouce-id value to match. <br />       |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### res

```
BySelector res (Pattern resourceName)
```

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.

<br />

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

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### scrollable

```
BySelector scrollable (boolean isScrollable)
```

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

<br />

|                                                      Parameters                                                      ||
|----------------|------------------------------------------------------------------------------------------------------|
| `isScrollable` | `boolean`: Whether to match elements that are scrollable or elements that are not scrollable. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### selected

```
BySelector selected (boolean isSelected)
```

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

<br />

|                                                   Parameters                                                   ||
|--------------|--------------------------------------------------------------------------------------------------|
| `isSelected` | `boolean`: Whether to match elements that are selected or elements that are not selected. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### text

```
BySelector text (Pattern textValue)
```

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.

<br />

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

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### text

```
BySelector text (String textValue)
```

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

<br />

|                       Parameters                        ||
|-------------|--------------------------------------------|
| `textValue` | `String`: The exact value to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### textContains

```
BySelector textContains (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### textEndsWith

```
BySelector textEndsWith (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### textStartsWith

```
BySelector textStartsWith (String substring)
```

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

<br />

|                      Parameters                       ||
|-------------|------------------------------------------|
| `substring` | `String`: The substring to match. <br /> |

|                                                                                                             Returns                                                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector) | A reference to this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). <br /> |

### toString

```
String toString ()
```

Returns a[String](https://developer.android.com/reference/java/lang/String.html)representation of this[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector). The format is "BySelector \[\<KEY\>='\<VALUE\> ... \]". 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).

<br />

|                                     Returns                                     ||
|-------------------------------------------------------------------------|--------|
| [String](https://developer.android.com/reference/java/lang/String.html) | <br /> |

-

  ## Interfaces

  - [IAutomationSupport](https://developer.android.com/reference/android/support/test/uiautomator/IAutomationSupport)
  - [UiWatcher](https://developer.android.com/reference/android/support/test/uiautomator/UiWatcher)
-

  ## Classes

  - [By](https://developer.android.com/reference/android/support/test/uiautomator/By)
  - [BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)
  - [Configurator](https://developer.android.com/reference/android/support/test/uiautomator/Configurator)
  - [EventCondition](https://developer.android.com/reference/android/support/test/uiautomator/EventCondition)
  - [SearchCondition](https://developer.android.com/reference/android/support/test/uiautomator/SearchCondition)
  - [UiAutomatorInstrumentationTestRunner](https://developer.android.com/reference/android/support/test/uiautomator/UiAutomatorInstrumentationTestRunner)
  - [UiAutomatorTestCase](https://developer.android.com/reference/android/support/test/uiautomator/UiAutomatorTestCase)
  - [UiCollection](https://developer.android.com/reference/android/support/test/uiautomator/UiCollection)
  - [UiDevice](https://developer.android.com/reference/android/support/test/uiautomator/UiDevice)
  - [UiObject](https://developer.android.com/reference/android/support/test/uiautomator/UiObject)
  - [UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)
  - [UiObject2Condition](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2Condition)
  - [UiScrollable](https://developer.android.com/reference/android/support/test/uiautomator/UiScrollable)
  - [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)
  - [Until](https://developer.android.com/reference/android/support/test/uiautomator/Until)
-

  ## Enums

  - [Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)
-

  ## Exceptions

  - [StaleObjectException](https://developer.android.com/reference/android/support/test/uiautomator/StaleObjectException)
  - [UiObjectNotFoundException](https://developer.android.com/reference/android/support/test/uiautomator/UiObjectNotFoundException)