A bit late, but here are some tips.
Remember that you can use the UI Automator Viewer to identify resource identifiers, etc. AndroidSDKPath \ tools \ uiautomatorviewer
A few considerations that change the approach to this.
- Are the items available in the list?
- Are the items in the list the same size?
- Do elements contain separate text fields?
Assuming the items in the list can be clicked, you can use the selector as follows:
UiSelector selector = new UiSelector().clickable(true);
, Java , .
, . , , , , ( ). , , .
, , , 0.
:
UiObject list = device.findObject(new UiSelector().resourceId(PACKAGE + ":id/" + resourceId));
int index = 0;
int count = 0;
while (index < list.getChildCount()) {
UiObject listItem = list.getChild(selector.index(index));
Set<String> examinedItems = new LinkedHashSet<>();
if (listItem.getBounds().top < TOOLBAR_BOTTOM_Y) {
index++;
continue;
}
String itemDetails = ...;
if (examinedItems.contains(itemDetails)) {
index++;
continue;
}
count++;
if (index == 0) {
TouchUtils.drag(this, CENTER_X, CENTER_X, START_SCROLL_Y, START_SCROLL_Y - ITEM_HEIGHT, 150);
}
examinedItems.add(itemDetails);
}