(iOS) Does findElementByName(String Name) support regexp?

Does findElementByName(String Name) support regexp FOR iOS?

I have a list contains some text, e.g. sunny_Monday, rainy_Tuesday, cloud_Wednesday…

I want to use the method like:


to click the text “sunny_Monday”, but it doesn’t work.
Since I could not get the full text (only can get the ‘sunny’, ‘rainy’, ‘cloud’, the suffix is dynamic for every word), Is there any other way to achieve this?


An alternative would be to useUiSelector, which supports regex.


textMatches(String regex)
resourceIdMatches(String regex)
packageNameMatches(String regex)
descriptionMatches(String regex)
classNameMatches(String regex)

Or xpath “contains()”.

thanks for your comments, but I’m testing on iOS…

Appium has native iOS automation support (try predicates), or you could use xpath. I suggest trying native first.


For example:


can be replaced with (as a VERY generic example)

driver.findElement(MobileBy.IosUIAutomation(“au.mainApp().getFirstWithPredicate(“name CONTAINS ‘sunny’”)”)).click();

I would specify type of an element as well as get a list of elements that fit the criteria and work with that.

or if you prefer xpath (which I don’t recommend)

driver.findElement(By.xpath("//*[contains(@name, ‘sunny’)]]")).click();

Thanks Simon!
It works using xpath.

And I will try to use your recommend method “MobileBy.IosUIAutomation” to verify which way is best.

Thanks again!