I am trying to validate text in each list item in my ListView and scroll down one by one so I can validate each one... but for some reason I cant get it to continue scrolling through the list validating each element. Has anyone had any luck automating this kind of action.Here is the closest I can come to. Please let me know if this isn't enough info:
UiScrollable scrollableList = new UiScrollable(new UiSelector()
.resourceId("com.example.app:id/listView")
.className(android.widget.ListView.class.getName())
.index(3));
for ( i = 0; i < 100; i++ ) {
UiObject listItem = scrollableList.getChildByText(new UiSelector()
.className("android.widget.RelativeLayout")
.instance(i), "Text Title");
UiObject textBody = listItem.getFromParent(new UiSelector()
.resourceId("com.example.app:id/textBody"));
System.out.println("Validating: " + textBody.getText());
There are only 5 listItems visible on the screen at the time, so it fails when it tries to get to number 6, which it cant because:
a. it wont try to scroll forward to get the next one in the list
b. even if it did scroll forward to get the next one in the list, the instance value will decrease to 5, instead of increasing to 6.
I have tried it without the .instance() method, but in that case it just loops over the first item in the list over and over without progressing to item 2,3,4 ect.
If anyone has come across this issue, I would love feedback.