public class

UiCollection

extends UiObject
java.lang.Object
   ↳ android.support.test.uiautomator.UiObject
     ↳ android.support.test.uiautomator.UiCollection
Known Direct Subclasses

Class Overview

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

[Expand]
Inherited Constants
From class android.support.test.uiautomator.UiObject
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.
[Expand]
Inherited Methods
From class android.support.test.uiautomator.UiObject
From class java.lang.Object

Public Constructors

public UiCollection (UiSelector selector)

Constructs an instance as described by the selector

Public Methods

public 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 selector of the child pattern to match and return
text String of the identifying child contents of of the childPattern
Returns
  • UiObject pointing at and instance of childPattern
Throws
UiObjectNotFoundException
UiObjectNotFoundException

public 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 selector of the child pattern to match and return
instance int the desired matched instance of this childPattern
Returns
  • UiObject pointing at and instance of childPattern

public 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 selector of the child pattern to match and return
text String of the identifying child contents of of the childPattern
Returns
  • UiObject pointing at and instance of childPattern
Throws
UiObjectNotFoundException
UiObjectNotFoundException

public 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 a UiSelector that represents the matching child UI elements to count
Returns
  • the number of matched childPattern under the current UiCollection