I am trying to check the text in each element of a list in my ListView and scroll down one at a time so that I can check each of them ... but for some reason I cannot make it continue to scroll through the list that checks each element. Someone had luck automating such an action. Here is the closest I can come to. Please let me know if this is not enough.
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());
Currently there are only 5 listItems on the screen, so it fails when it tries to get to number 6, which it cannot, because:
a. he will not try to scroll forward to get the next one on the list
b. , even if he scrolled forward to get the next one on the list, the instance value will decrease to 5, instead of increasing to 6.
I tried this without the .instance () method, but in this case, it again and again iterates over the first item in the list, without going to paragraph 2,3,4 ect.
If anyone ran into this problem, I would love the feedback.
source share