Is it possible to select multiple emlements using Accessibility IDs and wildcards?

I know this can be done with XPath. But I have accessibility IDs that are regular. Like:
footer.btn.Jun 25, 2021
footer.btn.Jun 26, 2021
footer.btn.Jun 28, 2021

I would like to be able to say:

btns = driver.elementsByAccessibilityIdPattern("footer.btn*");
btns.forEach(btn => ....);

where you can select multiple Id with ‘*’:
iOS:

  • iOSNsPredicateString
  • iOSClassChain

Android:

  • AndroidUIAutomator
1 Like

Very good!
I have been playing with iOSClassChain:
let e = driver.elements('-ios class chain','**/some/chain/')

What is iOSNsPredicateString?

https://appium.io/docs/en/writing-running-appium/ios/ios-predicate/

You need use ‘contain’

This looks very interesting. How do I get at these APIs using Javascipt/WD?

examples: https://github.com/appium/appium/blob/master/sample-code/javascript-wd/test/basic/ios-selectors.test.js

1 Like

Thanks. That is a very useful page.

After I typed my ;last question I found that: await driver.elements('-ios predicate string', base_url_iosp); (where base_url_iosp is a predicate string I got from the appium front end) returns a array(ish) object.

Is there a way I can find those predicate strings by examining the code, rather than by using the appium front end?

I use result of “driver.getPageSource()” (Java) on needed screen. then I am looking what we have: name, value or label.

also example: https://github.com/facebookarchive/WebDriverAgent/wiki/Predicate-Queries-Construction-Rules

PS when something needed I am adding accessibility IDs into iOS code myself.

Yes, me too. I have the power.

But they do not always work. They seem particularly unreliable for static elements like labels. Early days yet for me.

I also am having no luck using them on “popover” windows.