UiCollectionpublic class UiCollection extends UiObject 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. |
Constructors Summary |
---|
public UiCollection(UiSelector selector)Constructs an instance as described by the selector
super(selector);
|
Methods Summary |
---|
public UiObject | getChildByDescription(UiSelector childPattern, java.lang.String text)Searches for child UI element within the constraints of this UiCollection {@link 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.
Tracer.trace(childPattern, text);
if (text != null) {
int count = getChildCount(childPattern);
for (int x = 0; x < count; x++) {
UiObject row = getChildByInstance(childPattern, x);
String nodeDesc = row.getContentDescription();
if(nodeDesc != null && nodeDesc.contains(text)) {
return row;
}
UiObject item = row.getChild(new UiSelector().descriptionContains(text));
if (item.exists()) {
return row;
}
}
}
throw new UiObjectNotFoundException("for description= \"" + text + "\"");
| public UiObject | getChildByInstance(UiSelector childPattern, int instance)Searches for child UI element within the constraints of this UiCollection {@link 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.
Tracer.trace(childPattern, instance);
UiSelector patternSelector = UiSelector.patternBuilder(getSelector(),
UiSelector.patternBuilder(childPattern).instance(instance));
return new UiObject(patternSelector);
| public UiObject | getChildByText(UiSelector childPattern, java.lang.String text)Searches for child UI element within the constraints of this UiCollection {@link 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.
Tracer.trace(childPattern, text);
if (text != null) {
int count = getChildCount(childPattern);
for (int x = 0; x < count; x++) {
UiObject row = getChildByInstance(childPattern, x);
String nodeText = row.getText();
if(text.equals(nodeText)) {
return row;
}
UiObject item = row.getChild(new UiSelector().text(text));
if (item.exists()) {
return row;
}
}
}
throw new UiObjectNotFoundException("for text= \"" + text + "\"");
| 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.
Tracer.trace(childPattern);
UiSelector patternSelector =
UiSelector.patternBuilder(getSelector(), UiSelector.patternBuilder(childPattern));
return getQueryController().getPatternCount(patternSelector);
|
|