# UiObject2

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

# UiObject2

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

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

<br />

*** ** * ** ***

A[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)represents a UI element. Unlike[UiObject](https://developer.android.com/reference/android/support/test/uiautomator/UiObject), it is bound to a particular view instance and can become stale if the underlying view object is destroyed. As a result, it may be necessary to call[findObject(BySelector)](https://developer.android.com/reference/android/support/test/uiautomator/UiDevice#findObject(android.support.test.uiautomator.BySelector))to obtain a new[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)instance if the UI changes significantly.

## Summary

|                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                        ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                                                                                     | ` `[clear](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#clear())`() ` Clears the text content if this object is an editable field.                                                                                                                                                                                                                                           |
| ` void`                                                                                                                                                                     | ` `[click](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#click())`() ` Clicks on this object.                                                                                                                                                                                                                                                                                 |
| ` void`                                                                                                                                                                     | ` `[click](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#click(long))`(long duration) ` Performs a click on this object that lasts for`duration`milliseconds.                                                                                                                                                                                                                 |
| ` <R> R`                                                                                                                                                                    | ` `[clickAndWait](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#clickAndWait(android.support.test.uiautomator.EventCondition<R>, long))`(`[EventCondition](https://developer.android.com/reference/android/support/test/uiautomator/EventCondition)`<R> condition, long timeout) ` Clicks on this object, and waits for the given condition to become true.                   |
| ` void`                                                                                                                                                                     | ` `[drag](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#drag(android.graphics.Point))`(`[Point](https://developer.android.com/reference/android/graphics/Point.html)` dest) ` Drags this object to the specified location.                                                                                                                                                    |
| ` void`                                                                                                                                                                     | ` `[drag](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#drag(android.graphics.Point, int))`(`[Point](https://developer.android.com/reference/android/graphics/Point.html)` dest, int speed) ` Drags this object to the specified location.                                                                                                                                    |
| ` boolean`                                                                                                                                                                  | ` `[equals](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object.html)` object) ` <br />                                                                                                                                                                                               |
| ` `[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)                                                                          | ` `[findObject](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#findObject(android.support.test.uiautomator.BySelector))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` selector) ` Searches all elements under this object and returns the first object to match the criteria, or null if no matching objects are found. |
| ` `[List](https://developer.android.com/reference/java/util/List.html)`<`[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)`>` | ` `[findObjects](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#findObjects(android.support.test.uiautomator.BySelector))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` selector) ` Searches all elements under this object and returns all objects that match the criteria.                                            |
| ` boolean`                                                                                                                                                                  | ` `[fling](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#fling(android.support.test.uiautomator.Direction, int))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction, int speed) ` Performs a fling gesture on this object.                                                                                          |
| ` boolean`                                                                                                                                                                  | ` `[fling](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#fling(android.support.test.uiautomator.Direction))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction) ` Performs a fling gesture on this object.                                                                                                          |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                                                                                                  | ` `[getApplicationPackage](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getApplicationPackage())`() ` Returns the package name of the app that this object belongs to.                                                                                                                                                                                                       |
| ` int`                                                                                                                                                                      | ` `[getChildCount](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getChildCount())`() ` Returns the number of child elements directly under this object.                                                                                                                                                                                                                       |
| ` `[List](https://developer.android.com/reference/java/util/List.html)`<`[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)`>` | ` `[getChildren](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getChildren())`() ` Returns a collection of the child elements directly under this object.                                                                                                                                                                                                                     |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                                                                                                  | ` `[getClassName](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getClassName())`() ` Returns the class name of the underlying[View](https://developer.android.com/reference/android/view/View.html)represented by this object.                                                                                                                                                |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                                                                                                  | ` `[getContentDescription](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getContentDescription())`() ` Returns the content description for this object.                                                                                                                                                                                                                       |
| ` `[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)                                                                          | ` `[getParent](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getParent())`() ` Returns this object's parent, or null if it has no parent.                                                                                                                                                                                                                                     |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                                                                                                  | ` `[getResourceName](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getResourceName())`() ` Returns the fully qualified resource name for this object's id.                                                                                                                                                                                                                    |
| ` `[String](https://developer.android.com/reference/java/lang/String.html)                                                                                                  | ` `[getText](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getText())`() ` Returns the text value for this object.                                                                                                                                                                                                                                                            |
| ` `[Rect](https://developer.android.com/reference/android/graphics/Rect.html)                                                                                               | ` `[getVisibleBounds](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getVisibleBounds())`() ` Returns the visible bounds of this object in screen coordinates.                                                                                                                                                                                                                 |
| ` `[Point](https://developer.android.com/reference/android/graphics/Point.html)                                                                                             | ` `[getVisibleCenter](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#getVisibleCenter())`() ` Returns a point in the center of the visible bounds of this object.                                                                                                                                                                                                              |
| ` boolean`                                                                                                                                                                  | ` `[hasObject](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#hasObject(android.support.test.uiautomator.BySelector))`(`[BySelector](https://developer.android.com/reference/android/support/test/uiautomator/BySelector)` selector) ` Returns whether there is a match for the given criteria under this object.                                                              |
| ` int`                                                                                                                                                                      | ` `[hashCode](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#hashCode())`() ` <br />                                                                                                                                                                                                                                                                                           |
| ` boolean`                                                                                                                                                                  | ` `[isCheckable](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isCheckable())`() ` Returns whether this object is checkable.                                                                                                                                                                                                                                                  |
| ` boolean`                                                                                                                                                                  | ` `[isChecked](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isChecked())`() ` Returns whether this object is checked.                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                                                                                  | ` `[isClickable](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isClickable())`() ` Returns whether this object is clickable.                                                                                                                                                                                                                                                  |
| ` boolean`                                                                                                                                                                  | ` `[isEnabled](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isEnabled())`() ` Returns whether this object is enabled.                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                                                                                  | ` `[isFocusable](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isFocusable())`() ` Returns whether this object is focusable.                                                                                                                                                                                                                                                  |
| ` boolean`                                                                                                                                                                  | ` `[isFocused](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isFocused())`() ` Returns whether this object is focused.                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                                                                                  | ` `[isLongClickable](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isLongClickable())`() ` Returns whether this object is long clickable.                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                                                                                  | ` `[isScrollable](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isScrollable())`() ` Returns whether this object is scrollable.                                                                                                                                                                                                                                               |
| ` boolean`                                                                                                                                                                  | ` `[isSelected](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#isSelected())`() ` Returns whether this object is selected.                                                                                                                                                                                                                                                     |
| ` void`                                                                                                                                                                     | ` `[longClick](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#longClick())`() ` Performs a long click on this object.                                                                                                                                                                                                                                                          |
| ` void`                                                                                                                                                                     | ` `[pinchClose](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#pinchClose(float))`(float percent) ` Performs a pinch close gesture on this object.                                                                                                                                                                                                                             |
| ` void`                                                                                                                                                                     | ` `[pinchClose](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#pinchClose(float, int))`(float percent, int speed) ` Performs a pinch close gesture on this object.                                                                                                                                                                                                             |
| ` void`                                                                                                                                                                     | ` `[pinchOpen](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#pinchOpen(float))`(float percent) ` Performs a pinch open gesture on this object.                                                                                                                                                                                                                                |
| ` void`                                                                                                                                                                     | ` `[pinchOpen](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#pinchOpen(float, int))`(float percent, int speed) ` Performs a pinch open gesture on this object.                                                                                                                                                                                                                |
| ` void`                                                                                                                                                                     | ` `[recycle](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#recycle())`() ` Recycle this object.                                                                                                                                                                                                                                                                               |
| ` boolean`                                                                                                                                                                  | ` `[scroll](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#scroll(android.support.test.uiautomator.Direction, float, int))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction, float percent, int speed) ` Performs a scroll gesture on this object.                                                                 |
| ` boolean`                                                                                                                                                                  | ` `[scroll](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#scroll(android.support.test.uiautomator.Direction, float))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction, float percent) ` Performs a scroll gesture on this object.                                                                                 |
| ` void`                                                                                                                                                                     | ` `[setGestureMargin](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#setGestureMargin(int))`(int margin) ` Sets the margins used for gestures in pixels.                                                                                                                                                                                                                       |
| ` void`                                                                                                                                                                     | ` `[setGestureMargins](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#setGestureMargins(int, int, int, int))`(int left, int top, int right, int bottom) ` Sets the margins used for gestures in pixels.                                                                                                                                                                        |
| ` void`                                                                                                                                                                     | ` `[setText](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#setText(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String.html)` text) ` Sets the text content if this object is an editable field.                                                                                                                                           |
| ` void`                                                                                                                                                                     | ` `[swipe](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#swipe(android.support.test.uiautomator.Direction, float, int))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction, float percent, int speed) ` Performs a swipe gesture on this object.                                                                    |
| ` void`                                                                                                                                                                     | ` `[swipe](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#swipe(android.support.test.uiautomator.Direction, float))`(`[Direction](https://developer.android.com/reference/android/support/test/uiautomator/Direction)` direction, float percent) ` Performs a swipe gesture on this object.                                                                                    |
| ` <R> R`                                                                                                                                                                    | ` `[wait](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#wait(android.support.test.uiautomator.UiObject2Condition<R>, long))`(`[UiObject2Condition](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2Condition)`<R> condition, long timeout) ` Waits for given the`condition`to be met.                                                       |
| ` <R> R`                                                                                                                                                                    | ` `[wait](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2#wait(android.support.test.uiautomator.SearchCondition<R>, long))`(`[SearchCondition](https://developer.android.com/reference/android/support/test/uiautomator/SearchCondition)`<R> condition, long timeout) ` Waits for given the`condition`to be met.                                                                |

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

### clear

```
void clear ()
```

Clears the text content if this object is an editable field.

<br />

### click

```
void click ()
```

Clicks on this object.

<br />

### click

```
void click (long duration)
```

Performs a click on this object that lasts for`duration`milliseconds.

<br />

|        Parameters         ||
|------------|---------------|
| `duration` | `long` <br /> |

### clickAndWait

```
R clickAndWait (EventCondition<R> condition, 
                long timeout)
```

Clicks on this object, and waits for the given condition to become true.

<br />

|              Parameters              ||
|-------------|-------------------------|
| `condition` | `EventCondition` <br /> |
| `timeout`   | `long` <br />           |

|   Returns   ||
|-----|--------|
| `R` | <br /> |

### drag

```
void drag (Point dest)
```

Drags this object to the specified location.

<br />

|                                  Parameters                                  ||
|--------|----------------------------------------------------------------------|
| `dest` | `Point`: The end point that this object should be dragged to. <br /> |

### drag

```
void drag (Point dest, 
                int speed)
```

Drags this object to the specified location.

<br />

|                                       Parameters                                        ||
|---------|--------------------------------------------------------------------------------|
| `dest`  | `Point`: The end point that this object should be dragged to. <br />           |
| `speed` | `int`: The speed at which to perform this gesture in pixels per second. <br /> |

### equals

```
boolean equals (Object object)
```

<br />

<br />

|        Parameters         ||
|----------|-----------------|
| `object` | `Object` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### findObject

```
UiObject2 findObject (BySelector selector)
```

Searches all elements under this object and returns the first object to match the criteria, or null if no matching objects are found.

<br />

|           Parameters            ||
|------------|---------------------|
| `selector` | `BySelector` <br /> |

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

### findObjects

```
List<UiObject2> findObjects (BySelector selector)
```

Searches all elements under this object and returns all objects that match the criteria.

<br />

|           Parameters            ||
|------------|---------------------|
| `selector` | `BySelector` <br /> |

|                                                                                     Returns                                                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List.html)`<`[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)`>` | <br /> |

### fling

```
boolean fling (Direction direction, 
                int speed)
```

Performs a fling gesture on this object.

<br />

|                                         Parameters                                          ||
|-------------|--------------------------------------------------------------------------------|
| `direction` | `Direction`: The direction in which to fling. <br />                           |
| `speed`     | `int`: The speed at which to perform this gesture in pixels per second. <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | Whether the object can still scroll in the given direction. <br /> |

### fling

```
boolean fling (Direction direction)
```

Performs a fling gesture on this object.

<br />

|                            Parameters                             ||
|-------------|------------------------------------------------------|
| `direction` | `Direction`: The direction in which to fling. <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | Whether the object can still scroll in the given direction. <br /> |

### getApplicationPackage

```
String getApplicationPackage ()
```

Returns the package name of the app that this object belongs to.

<br />

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

### getChildCount

```
int getChildCount ()
```

Returns the number of child elements directly under this object.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getChildren

```
List<UiObject2> getChildren ()
```

Returns a collection of the child elements directly under this object.

<br />

|                                                                                     Returns                                                                                      ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List.html)`<`[UiObject2](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2)`>` | <br /> |

### getClassName

```
String getClassName ()
```

Returns the class name of the underlying[View](https://developer.android.com/reference/android/view/View.html)represented by this object.

<br />

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

### getContentDescription

```
String getContentDescription ()
```

Returns the content description for this object.

<br />

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

### getParent

```
UiObject2 getParent ()
```

Returns this object's parent, or null if it has no parent.

<br />

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

### getResourceName

```
String getResourceName ()
```

Returns the fully qualified resource name for this object's id.

<br />

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

### getText

```
String getText ()
```

Returns the text value for this object.

<br />

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

### getVisibleBounds

```
Rect getVisibleBounds ()
```

Returns the visible bounds of this object in screen coordinates.

<br />

|                                      Returns                                       ||
|----------------------------------------------------------------------------|--------|
| [Rect](https://developer.android.com/reference/android/graphics/Rect.html) | <br /> |

### getVisibleCenter

```
Point getVisibleCenter ()
```

Returns a point in the center of the visible bounds of this object.

<br />

|                                       Returns                                        ||
|------------------------------------------------------------------------------|--------|
| [Point](https://developer.android.com/reference/android/graphics/Point.html) | <br /> |

### hasObject

```
boolean hasObject (BySelector selector)
```

Returns whether there is a match for the given criteria under this object.

<br />

|           Parameters            ||
|------------|---------------------|
| `selector` | `BySelector` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### hashCode

```
int hashCode ()
```

<br />

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### isCheckable

```
boolean isCheckable ()
```

Returns whether this object is checkable.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isChecked

```
boolean isChecked ()
```

Returns whether this object is checked.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isClickable

```
boolean isClickable ()
```

Returns whether this object is clickable.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isEnabled

```
boolean isEnabled ()
```

Returns whether this object is enabled.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isFocusable

```
boolean isFocusable ()
```

Returns whether this object is focusable.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isFocused

```
boolean isFocused ()
```

Returns whether this object is focused.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isLongClickable

```
boolean isLongClickable ()
```

Returns whether this object is long clickable.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isScrollable

```
boolean isScrollable ()
```

Returns whether this object is scrollable.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isSelected

```
boolean isSelected ()
```

Returns whether this object is selected.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### longClick

```
void longClick ()
```

Performs a long click on this object.

<br />

### pinchClose

```
void pinchClose (float percent)
```

Performs a pinch close gesture on this object.

<br />

|                                       Parameters                                        ||
|-----------|------------------------------------------------------------------------------|
| `percent` | `float`: The size of the pinch as a percentage of this object's size. <br /> |

### pinchClose

```
void pinchClose (float percent, 
                int speed)
```

Performs a pinch close gesture on this object.

<br />

|                                        Parameters                                         ||
|-----------|--------------------------------------------------------------------------------|
| `percent` | `float`: The size of the pinch as a percentage of this object's size. <br />   |
| `speed`   | `int`: The speed at which to perform this gesture in pixels per second. <br /> |

### pinchOpen

```
void pinchOpen (float percent)
```

Performs a pinch open gesture on this object.

<br />

|                                       Parameters                                        ||
|-----------|------------------------------------------------------------------------------|
| `percent` | `float`: The size of the pinch as a percentage of this object's size. <br /> |

### pinchOpen

```
void pinchOpen (float percent, 
                int speed)
```

Performs a pinch open gesture on this object.

<br />

|                                        Parameters                                         ||
|-----------|--------------------------------------------------------------------------------|
| `percent` | `float`: The size of the pinch as a percentage of this object's size. <br />   |
| `speed`   | `int`: The speed at which to perform this gesture in pixels per second. <br /> |

### recycle

```
void recycle ()
```

Recycle this object.

<br />

### scroll

```
boolean scroll (Direction direction, 
                float percent, 
                int speed)
```

Performs a scroll gesture on this object.

<br />

|                                             Parameters                                             ||
|-------------|---------------------------------------------------------------------------------------|
| `direction` | `Direction`: The direction in which to scroll. <br />                                 |
| `percent`   | `float`: The distance to scroll as a percentage of this object's visible size. <br /> |
| `speed`     | `int`: The speed at which to perform this gesture in pixels per second. <br />        |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | Whether the object can still scroll in the given direction. <br /> |

### scroll

```
boolean scroll (Direction direction, 
                float percent)
```

Performs a scroll gesture on this object.

<br />

|                                             Parameters                                             ||
|-------------|---------------------------------------------------------------------------------------|
| `direction` | `Direction`: The direction in which to scroll. <br />                                 |
| `percent`   | `float`: The distance to scroll as a percentage of this object's visible size. <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | Whether the object can still scroll in the given direction. <br /> |

### setGestureMargin

```
void setGestureMargin (int margin)
```

Sets the margins used for gestures in pixels.

<br />

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

### setGestureMargins

```
void setGestureMargins (int left, 
                int top, 
                int right, 
                int bottom)
```

Sets the margins used for gestures in pixels.

<br />

|       Parameters       ||
|----------|--------------|
| `left`   | `int` <br /> |
| `top`    | `int` <br /> |
| `right`  | `int` <br /> |
| `bottom` | `int` <br /> |

### setText

```
void setText (String text)
```

Sets the text content if this object is an editable field.

<br />

|       Parameters        ||
|--------|-----------------|
| `text` | `String` <br /> |

### swipe

```
void swipe (Direction direction, 
                float percent, 
                int speed)
```

Performs a swipe gesture on this object.

<br />

|                                         Parameters                                          ||
|-------------|--------------------------------------------------------------------------------|
| `direction` | `Direction`: The direction in which to swipe. <br />                           |
| `percent`   | `float`: The length of the swipe as a percentage of this object's size. <br /> |
| `speed`     | `int`: The speed at which to perform this gesture in pixels per second. <br /> |

### swipe

```
void swipe (Direction direction, 
                float percent)
```

Performs a swipe gesture on this object.

<br />

|                                         Parameters                                          ||
|-------------|--------------------------------------------------------------------------------|
| `direction` | `Direction`: The direction in which to swipe. <br />                           |
| `percent`   | `float`: The length of the swipe as a percentage of this object's size. <br /> |

### wait

```
R wait (UiObject2Condition<R> condition, 
                long timeout)
```

Waits for given the`condition`to be met.

<br />

|                                                                                 Parameters                                                                                 ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `condition` | `UiObject2Condition`: The[UiObject2Condition](https://developer.android.com/reference/android/support/test/uiautomator/UiObject2Condition)to evaluate. <br /> |
| `timeout`   | `long`: Maximum amount of time to wait in milliseconds. <br />                                                                                                |

|                                                      Returns                                                       ||
|-----|---------------------------------------------------------------------------------------------------------------|
| `R` | The final result returned by the`condition`, or null if the`condition`was not met before the`timeout`. <br /> |

### wait

```
R wait (SearchCondition<R> condition, 
                long timeout)
```

Waits for given the`condition`to be met.

<br />

|                                                                            Parameters                                                                             ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `condition` | `SearchCondition`: The[SearchCondition](https://developer.android.com/reference/android/support/test/uiautomator/SearchCondition)to evaluate. <br /> |
| `timeout`   | `long`: Maximum amount of time to wait in milliseconds. <br />                                                                                       |

|                                                      Returns                                                       ||
|-----|---------------------------------------------------------------------------------------------------------------|
| `R` | The final result returned by the`condition`, or null if the`condition`was not met before the`timeout`. <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)