appium-uiautomator2-server icon indicating copy to clipboard operation
appium-uiautomator2-server copied to clipboard

classNameMatches doesn't return all results

Open gavrix opened this issue 3 years ago • 3 comments
trafficstars

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.

gavrix avatar May 27 '22 22:05 gavrix

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.

KazuCocoa avatar May 28 '22 02:05 KazuCocoa

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.

gavrix avatar May 28 '22 14:05 gavrix

I see, thank you. I'll take a look

KazuCocoa avatar May 28 '22 15:05 KazuCocoa