iOS Selector - How to select the "next element of the same type"?

Hello everyone, I’m trying to find a way to tap on the next element of the same type.

For example, If I found a UIAButton with label “Today”, I want to tap on the next UIAButton (which would be “Tomorrow”, but it’s not ).

EDIT: I figured out that this works:

//UIAButton[@name=“Today”]/following-sibling::UIAButton[1]

But I’m looking for a native ios uiautomation solution.

I don’t think there’s a “native ios uiautomation” solution. Your use of XPATH axes is good, you can get some powerful XPATH searches that way (3rd element following a specific UIATableGroup, etc.).

You could get a list of all UIAButton, find the index of the one that has “Today” in the name, the increment the index to select the following button. Fairly boring, but straightforward, and dynamic in case the indexing changes.

I was looking for ios uiautomation solution, as I’m trying to stay away from xpath whenever possible. Iterating through elements is fine as well, I was just looking for a cleaner solution :slight_smile: