# UiSelector

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

# UiSelector

| 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
UiSelector
`  
`

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.UiSelector |

<br />

*** ** * ** ***

Specifies the elements in the layout hierarchy for tests to target, filtered by properties such as text value, content-description, class name, and state information. You can also target an element by its location in a layout hierarchy.

## Summary

|                                                  ### Public constructors                                                  ||
|------------------------------------------------------------------------------------------------------------------------|---|
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#UiSelector())`() ` |

|                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                        ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[checkable](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#checkable(boolean))`(boolean val) ` Set the search criteria to match widgets that are checkable.                                                                                                                                                                                   |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[checked](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#checked(boolean))`(boolean val) ` Set the search criteria to match widgets that are currently checked (usually for checkboxes).                                                                                                                                                      |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[childSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#childSelector(android.support.test.uiautomator.UiSelector))`(`[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)` selector) ` Adds a child UiSelector criteria to this selector.                                                |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[className](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#className(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` className) ` Set the search criteria to match the class property for a widget (for example, "android.widget.Button").                                                      |
| ` <T> `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | ` `[className](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#className(java.lang.Class<T>))`(`[Class](https://developer.android.com/reference/java/lang/Class.html)`<T> type) ` Set the search criteria to match the class property for a widget (for example, "android.widget.Button").                                                        |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[classNameMatches](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#classNameMatches(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` regex) ` Set the search criteria to match the class property for a widget, using a regular expression.                                                       |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[clickable](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#clickable(boolean))`(boolean val) ` Set the search criteria to match widgets that are clickable.                                                                                                                                                                                   |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[description](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#description(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` desc) ` Set the search criteria to match the content-description property for a widget.                                                                                |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[descriptionContains](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#descriptionContains(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` desc) ` Set the search criteria to match the content-description property for a widget.                                                                |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[descriptionMatches](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#descriptionMatches(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` regex) ` Set the search criteria to match the content-description property for a widget.                                                                 |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[descriptionStartsWith](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#descriptionStartsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` desc) ` Set the search criteria to match the content-description property for a widget.                                                            |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[enabled](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#enabled(boolean))`(boolean val) ` Set the search criteria to match widgets that are enabled.                                                                                                                                                                                         |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[focusable](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#focusable(boolean))`(boolean val) ` Set the search criteria to match widgets that are focusable.                                                                                                                                                                                   |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[focused](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#focused(boolean))`(boolean val) ` Set the search criteria to match widgets that have focus.                                                                                                                                                                                          |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[fromParent](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#fromParent(android.support.test.uiautomator.UiSelector))`(`[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)` selector) ` Adds a child UiSelector criteria to this selector which is used to start search from the parent widget. |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[index](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#index(int))`(int index) ` Set the search criteria to match the widget by its node index in the layout hierarchy.                                                                                                                                                                       |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[instance](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#instance(int))`(int instance) ` Set the search criteria to match the widget by its instance number.                                                                                                                                                                                 |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[longClickable](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#longClickable(boolean))`(boolean val) ` Set the search criteria to match widgets that are long-clickable.                                                                                                                                                                      |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[packageName](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#packageName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` name) ` Set the search criteria to match the package name of the application that contains the widget.                                                                 |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[packageNameMatches](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#packageNameMatches(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` regex) ` Set the search criteria to match the package name of the application that contains the widget.                                                  |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[resourceId](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#resourceId(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` id) ` Set the search criteria to match the given resource ID.                                                                                                            |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[resourceIdMatches](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#resourceIdMatches(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` regex) ` Set the search criteria to match the resource ID of the widget, using a regular expression.                                                       |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[scrollable](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#scrollable(boolean))`(boolean val) ` Set the search criteria to match widgets that are scrollable.                                                                                                                                                                                |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[selected](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#selected(boolean))`(boolean val) ` Set the search criteria to match widgets that are currently selected.                                                                                                                                                                            |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[text](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#text(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` text) ` Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app).                                                      |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[textContains](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#textContains(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` text) ` Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument.                         |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[textMatches](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#textMatches(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` regex) ` Set the search criteria to match the visible text displayed in a layout element, using a regular expression.                                                  |
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector)     | ` `[textStartsWith](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#textStartsWith(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` text) ` Set the search criteria to match visible text in a widget that is prefixed by the text parameter.                                                        |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                               | ` `[toString](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#toString())`() `                                                                                                                                                                                                                                                                    |

|                                                                                                       ### Protected methods                                                                                                        ||
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| ` `[UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | ` `[cloneSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#cloneSelector())`() ` |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#)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 constructors

### UiSelector

```
UiSelector ()
```

<br />

<br />

## Public methods

### checkable

```
UiSelector checkable (boolean val)
```

Set the search criteria to match widgets that are checkable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### checked

```
UiSelector checked (boolean val)
```

Set the search criteria to match widgets that are currently checked (usually for checkboxes). Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### childSelector

```
UiSelector childSelector (UiSelector selector)
```

Adds a child UiSelector criteria to this selector. Use this selector to narrow the search scope to child widgets under a specific parent widget.

<br />

|                                                                        Returns                                                                        ||
|---------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with this added search criterion <br /> |

### className

```
UiSelector className (String className)
```

Set the search criteria to match the class property for a widget (for example, "android.widget.Button").

<br />

|                  Parameters                  ||
|-------------|---------------------------------|
| `className` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### className

```
UiSelector className (Class<T> type)
```

Set the search criteria to match the class property for a widget (for example, "android.widget.Button").

<br />

|          Parameters          ||
|--------|----------------------|
| `type` | `Class`: type <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### classNameMatches

```
UiSelector classNameMatches (String regex)
```

Set the search criteria to match the class property for a widget, using a regular expression.

<br />

|                   Parameters                   ||
|---------|---------------------------------------|
| `regex` | `String`: a regular expression <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### clickable

```
UiSelector clickable (boolean val)
```

Set the search criteria to match widgets that are clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### description

```
UiSelector description (String desc)
```

Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument. Matching is case-sensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `desc` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### descriptionContains

```
UiSelector descriptionContains (String desc)
```

Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must contain the string in your input argument. Matching is case-insensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `desc` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### descriptionMatches

```
UiSelector descriptionMatches (String regex)
```

Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must match exactly with the string in your input argument.

<br />

|                   Parameters                   ||
|---------|---------------------------------------|
| `regex` | `String`: a regular expression <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### descriptionStartsWith

```
UiSelector descriptionStartsWith (String desc)
```

Set the search criteria to match the content-description property for a widget. The content-description is typically used by the Android Accessibility framework to provide an audio prompt for the widget when the widget is selected. The content-description for the widget must start with the string in your input argument. Matching is case-insensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `desc` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### enabled

```
UiSelector enabled (boolean val)
```

Set the search criteria to match widgets that are enabled. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### focusable

```
UiSelector focusable (boolean val)
```

Set the search criteria to match widgets that are focusable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### focused

```
UiSelector focused (boolean val)
```

Set the search criteria to match widgets that have focus. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### fromParent

```
UiSelector fromParent (UiSelector selector)
```

Adds a child UiSelector criteria to this selector which is used to start search from the parent widget. Use this selector to narrow the search scope to sibling widgets as well all child widgets under a parent.

<br />

|                                                                        Returns                                                                        ||
|---------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with this added search criterion <br /> |

### index

```
UiSelector index (int index)
```

Set the search criteria to match the widget by its node index in the layout hierarchy. The index value must be 0 or greater. Using the index can be unreliable and should only be used as a last resort for matching. Instead, consider using the[instance(int)](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#instance(int))method.

<br />

|              Parameters               ||
|---------|------------------------------|
| `index` | `int`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### instance

```
UiSelector instance (int instance)
```

Set the search criteria to match the widget by its instance number. The instance value must be 0 or greater, where the first instance is 0. For example, to simulate a user click on the third image that is enabled in a UI screen, you could specify a a search criteria where the instance is 2, the[className(String)](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#className(java.lang.String))matches the image widget class, and[enabled(boolean)](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector#enabled(boolean))is true. The code would look like this:`
new UiSelector().className("android.widget.ImageView")
.enabled(true).instance(2);
`

<br />

|                Parameters                ||
|------------|------------------------------|
| `instance` | `int`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### longClickable

```
UiSelector longClickable (boolean val)
```

Set the search criteria to match widgets that are long-clickable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### packageName

```
UiSelector packageName (String name)
```

Set the search criteria to match the package name of the application that contains the widget.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `name` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### packageNameMatches

```
UiSelector packageNameMatches (String regex)
```

Set the search criteria to match the package name of the application that contains the widget.

<br />

|                   Parameters                   ||
|---------|---------------------------------------|
| `regex` | `String`: a regular expression <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### resourceId

```
UiSelector resourceId (String id)
```

Set the search criteria to match the given resource ID.

<br />

|              Parameters               ||
|------|---------------------------------|
| `id` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### resourceIdMatches

```
UiSelector resourceIdMatches (String regex)
```

Set the search criteria to match the resource ID of the widget, using a regular expression.

<br />

|                   Parameters                   ||
|---------|---------------------------------------|
| `regex` | `String`: a regular expression <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### scrollable

```
UiSelector scrollable (boolean val)
```

Set the search criteria to match widgets that are scrollable. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### selected

```
UiSelector selected (boolean val)
```

Set the search criteria to match widgets that are currently selected. Typically, using this search criteria alone is not useful. You should also include additional criteria, such as text, content-description, or the class name for a widget. If no other search criteria is specified, and there is more than one matching widget, the first widget in the tree is selected.

<br />

|               Parameters                ||
|-------|----------------------------------|
| `val` | `boolean`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### text

```
UiSelector text (String text)
```

Set the search criteria to match the visible text displayed in a widget (for example, the text label to launch an app). The text for the element must match exactly with the string in your input argument. Matching is case-sensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `text` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### textContains

```
UiSelector textContains (String text)
```

Set the search criteria to match the visible text in a widget where the visible text must contain the string in your input argument. The matching is case-sensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `text` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### textMatches

```
UiSelector textMatches (String regex)
```

Set the search criteria to match the visible text displayed in a layout element, using a regular expression. The text in the widget must match exactly with the string in your input argument.

<br />

|                   Parameters                   ||
|---------|---------------------------------------|
| `regex` | `String`: a regular expression <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### textStartsWith

```
UiSelector textStartsWith (String text)
```

Set the search criteria to match visible text in a widget that is prefixed by the text parameter. The matching is case-insensitive.

<br />

|               Parameters                ||
|--------|---------------------------------|
| `text` | `String`: Value to match <br /> |

|                                                                         Returns                                                                         ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | UiSelector with the specified search criteria <br /> |

### toString

```
String toString ()
```

<br />

<br />

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

## Protected methods

### cloneSelector

```
UiSelector cloneSelector ()
```

<br />

<br />

|                                                  Returns                                                  ||
|---------------------------------------------------------------------------------------------------|--------|
| [UiSelector](https://developer.android.com/reference/android/support/test/uiautomator/UiSelector) | <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)