Summary: Inherited Constants | Ctors | Methods | Inherited Methods | [Expand All]

# UiCollection

`public class UiCollection`
`` `extends UiObject` ``

java.lang.Object
↳ | android.support.test.uiautomator.UiObject
| ↳ | android.support.test.uiautomator.UiCollection

Known Direct Subclasses UiScrollable
UiScrollable | UiScrollable is a `UiCollection` and provides support for searching for items in scrollable layout elements.

Used to enumerate a container's UI elements for the purpose of counting, or targeting a sub elements by a child's text or description.

## Summary

### Inherited constants
From class `android.support.test.uiautomator.UiObject`
`int` | `FINGER_TOUCH_HALF_WIDTH`
`int` | `SWIPE_MARGIN_LIMIT`
`long` | `WAIT_FOR_EVENT_TMEOUT` This constant is deprecated. use `setScrollAcknowledgmentTimeout(long)`
`long` | `WAIT_FOR_SELECTOR_POLL`
`long` | `WAIT_FOR_SELECTOR_TIMEOUT` This constant is deprecated. use `setWaitForSelectorTimeout(long)`
`long` | `WAIT_FOR_WINDOW_TMEOUT`

### Public constructors
`UiCollection(UiSelector selector)` Constructs an instance as described by the selector

### Public methods
`UiObject` | `getChildByDescription(UiSelector childPattern, String text)` Searches for child UI element within the constraints of this UiCollection `UiSelector` selector.
`UiObject` | `getChildByInstance(UiSelector childPattern, int instance)` Searches for child UI element within the constraints of this UiCollection `UiSelector` selector.
`UiObject` | `getChildByText(UiSelector childPattern, String text)` Searches for child UI element within the constraints of this UiCollection `UiSelector` selector.
`int` | `getChildCount(UiSelector childPattern)` Counts child UI element instances matching the `childPattern` argument.

### Inherited methods
From class `android.support.test.uiautomator.UiObject`
`void` | `clearTextField()` Clears the existing text contents in an editable field.
`boolean` | `click()` Performs a click at the center of the visible bounds of the UI element represented by this UiObject.
`boolean` | `clickAndWaitForNewWindow()` Waits for window transitions that would typically take longer than the usual default timeouts.
`boolean` | `clickAndWaitForNewWindow(long timeout)` Performs a click at the center of the visible bounds of the UI element represented by this UiObject and waits for window transitions.
`boolean` | `clickBottomRight()` Clicks the bottom and right corner of the UI element
`boolean` | `clickTopLeft()` Clicks the top and left corner of the UI element
`boolean` | `dragTo(UiObject destObj, int steps)` Drags this object to a destination UiObject.
`boolean` | `dragTo(int destX, int destY, int steps)` Drags this object to arbitrary coordinates.
`boolean` | `exists()` Check if view exists.
`AccessibilityNodeInfo` | `findAccessibilityNodeInfo(long timeout)` Finds a matching UI element in the accessibility hierarchy, by using the selector for this UiObject.
`Rect` | `getBounds()` Returns the view's `bounds` property.
`UiObject` | `getChild(UiSelector selector)` Creates a new UiObject for a child view that is under the present UiObject.
`int` | `getChildCount()` Counts the child views immediately under the present UiObject.
`String` | `getClassName()` Retrieves the `className` property of the UI element.
`String` | `getContentDescription()` Reads the `content_desc` property of the UI element
`UiObject` | `getFromParent(UiSelector selector)` Creates a new UiObject for a sibling view or a child of the sibling view, relative to the present UiObject.
`String` | `getPackageName()` Reads the view's `package` property
`final UiSelector` | `getSelector()` Debugging helper.
`String` | `getText()` Reads the `text` property of the UI element
`Rect` | `getVisibleBounds()` Returns the visible bounds of the view.
`boolean` | `isCheckable()` Checks if the UI element's `checkable` property is currently true.
`boolean` | `isChecked()` Check if the UI element's `checked` property is currently true
`boolean` | `isClickable()` Checks if the UI element's `clickable` property is currently true.
`boolean` | `isEnabled()` Checks if the UI element's `enabled` property is currently true.
`boolean` | `isFocusable()` Check if the UI element's `focusable` property is currently true.
`boolean` | `isFocused()` Check if the UI element's `focused` property is currently true
`boolean` | `isLongClickable()` Check if the view's `long-clickable` property is currently true
`boolean` | `isScrollable()` Check if the view's `scrollable` property is currently true
`boolean` | `isSelected()` Checks if the UI element's `selected` property is currently true.
`boolean` | `longClick()` Long clicks the center of the visible bounds of the UI element
`boolean` | `longClickBottomRight()` Long clicks bottom and right corner of the UI element
`boolean` | `longClickTopLeft()` Long clicks on the top and left corner of the UI element
`boolean` | `performMultiPointerGesture(PointerCoords... touches)` Performs a multi-touch gesture.
`boolean` | `performTwoPointerGesture(Point startPoint1, Point startPoint2, Point endPoint1, Point endPoint2, int steps)` Generates a two-pointer gesture with arbitrary starting and ending points.
`boolean` | `pinchIn(int percent, int steps)` Performs a two-pointer gesture, where each pointer moves diagonally toward the other, from the edges to the center of this UiObject .
`boolean` | `pinchOut(int percent, int steps)` Performs a two-pointer gesture, where each pointer moves diagonally opposite across the other, from the center out towards the edges of the this UiObject.
`boolean` | `setText(String text)` Sets the text in an editable field, after clearing the field's content.
`boolean` | `swipeDown(int steps)` Performs the swipe down action on the UiObject.
`boolean` | `swipeLeft(int steps)` Performs the swipe left action on the UiObject.
`boolean` | `swipeRight(int steps)` Performs the swipe right action on the UiObject.
`boolean` | `swipeUp(int steps)` Performs the swipe up action on the UiObject.
`boolean` | `waitForExists(long timeout)` Waits a specified length of time for a view to become visible.
`boolean` | `waitUntilGone(long timeout)` Waits a specified length of time for a view to become undetectable.
From class `java.lang.Object`
`Object` | `clone()`
`boolean` | `equals(Object arg0)`
`void` | `finalize()`
`final Class<?>` | `getClass()`
`int` | `hashCode()`
`final void` | `notify()`
`final void` | `notifyAll()`
`String` | `toString()`
`final void` | `wait(long arg0, int arg1)`
`final void` | `wait(long arg0)`
`final void` | `wait()`

## Public constructors

### UiCollection

    UiCollection (UiSelector selector)

Constructs an instance as described by the selector

## Public methods

### getChildByDescription

    UiObject getChildByDescription (UiSelector childPattern,
                    String text)

Searches for child UI element within the constraints of this UiCollection `UiSelector` selector. It looks for any child matching the `childPattern` argument that has a child UI element anywhere within its sub hierarchy that has content-description text. The returned UiObject will point at the `childPattern` instance that matched the search and not at the identifying child element that matched the content description.

Parameters
`childPattern` | `UiSelector`: `UiSelector` selector of the child pattern to match and return
`text` | `String`: String of the identifying child contents of of the `childPattern`

Returns
`UiObject` | `UiObject` pointing at and instance of `childPattern`

Throws
`` | UiObjectNotFoundException
`UiObjectNotFoundException` |

### getChildByInstance

    UiObject getChildByInstance (UiSelector childPattern,
                    int instance)

Searches for child UI element within the constraints of this UiCollection `UiSelector` selector. It looks for any child matching the `childPattern` argument that has a child UI element anywhere within its sub hierarchy that is at the `instance` specified. The operation is performed only on the visible items and no scrolling is performed in this case.

Parameters
`childPattern` | `UiSelector`: `UiSelector` selector of the child pattern to match and return
`instance` | `int`: int the desired matched instance of this `childPattern`

Returns
`UiObject` | `UiObject` pointing at and instance of `childPattern`

Throws
`UiObjectNotFoundException` |

### getChildByText

    UiObject getChildByText (UiSelector childPattern,
                    String text)

Searches for child UI element within the constraints of this UiCollection `UiSelector` selector. It looks for any child matching the `childPattern` argument that has a child UI element anywhere within its sub hierarchy that has text attribute = `text`. The returned UiObject will point at the `childPattern` instance that matched the search and not at the identifying child element that matched the text attribute.

Parameters
`childPattern` | `UiSelector`: `UiSelector` selector of the child pattern to match and return
`text` | `String`: String of the identifying child contents of of the `childPattern`

Returns
`UiObject` | `UiObject` pointing at and instance of `childPattern`

Throws
`` | UiObjectNotFoundException
`UiObjectNotFoundException` |

### getChildCount

    int getChildCount (UiSelector childPattern)

Counts child UI element instances matching the `childPattern` argument. The method returns the number of matching UI elements that are currently visible. The count does not include items of a scrollable list that are off-screen.

Parameters
`childPattern` | `UiSelector`: a `UiSelector` that represents the matching child UI elements to count

Returns
`int` | the number of matched childPattern under the current `UiCollection`

- ## Interfaces

  - IAutomationSupport
  - UiWatcher

- ## Classes

  - By
  - BySelector
  - Configurator
  - EventCondition
  - SearchCondition
  - UiAutomatorInstrumentationTestRunner
  - UiAutomatorTestCase
  - UiCollection
  - UiDevice
  - UiObject
  - UiObject2
  - UiObject2Condition
  - UiScrollable
  - UiSelector
  - Until

- ## Enums

  - Direction

- ## Exceptions

  - StaleObjectException
  - UiObjectNotFoundException