appium-uiautomator2-server
appium-uiautomator2-server copied to clipboard
classNameMatches doesn't return all results
Observing strange behaviour where selectors new UiSelector().className("android.view.ViewGroup") and new UiSelector().classNameMatches("android.view.ViewGroup") would return drastically different results (17 elements vs 5)
After some digging I found this issue https://github.com/appium/appium/issues/5924 which has been reported toward UiAutomator1 driver, however, based on the source code in this repo, it's still present.
Could you share the appium log?
Did you call it via -android uiautomator locator?
The query calls https://developer.android.com/reference/androidx/test/uiautomator/UiSelector method directly, so the result depends on how Android OS handles it.
As described in the original issue, it actually doesn't translate directly to UiSelector calls. This is the piece of code which handles class_regex selectors https://github.com/appium/appium-uiautomator2-server/blob/master/app/src/main/java/io/appium/uiautomator2/utils/ByUiAutomatorFinder.java#L101-L123
As described in the original issue, the useIndex part is confusing and what's probably broken.
I see, thank you. I'll take a look