i use RF+Appium
there are so many search result need to scroll several times, i would like to get the number of some items, and click each of them, like"Shell", i get the number use xpath: Get Matching Xpath Count | //XCUIElementTypeStaticText[@name=“Shell”], click each of them use: xpath=(//XCUIElementTypeStaticText[@name=“Shell”])[i]
the problem is :
work slow
will be no response when result is too many
is there a better way ?
@Aleksei, thank you reply so soon! other element i use nspredicate, but in my situation, i need to iterate all items named"Shell", click every “Shell” and verify some detail text, how to use nspredicate by index?
@Aleksei, thank you, i found another way, i use Get Webelements to put nsp=type==“XCUIElementTypeStaticText” AND name==“Shell”
in to list a, then click every “Shell” via a[i]
yes, this work faster! there is a new problem puzzles me:pensive:
in current screen only include three element that named ‘Shell’, when click a[4], will no response in app, but run result is successful, it seems like can’t found a[4], it is strange that can’t click a[4] also after swipe until a[4] is visible
Remember in iOS we can see elements outside screen. Thus if wr want tap on it - we need scroll first. With android we can see only elements which are on screen.
Get number of elements before you scroll. Are you visible all 4? There is a possibility that app dynamically adds new cells while you scroll.
I’ve get a better way! step1: i got the number of tab cells and every screen cells show, step2: calculating the scrolling times based on step1 and put the scrolling times in a for loop, step3: in for loop, get the number of element named “Shell” in each screen. i’m so happy that resolved this situation perfect!