-
-
Notifications
You must be signed in to change notification settings - Fork 764
findElementsByAndroidUIAutomator can only get the first element ,not all elements if uiAutomator expression with childSelector or fromParent ? #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
so,how to user findElementsByAndroidUIAutomator to get all elements which are children of another element? is there anything wrong with my uiatomator expression ? or is something wrong whith findElementsByAndroidUIAutomator ? |
Hmm, you're UIAutomator expression looks ok. The way I would debug this is by creating an actual UIAutomator test and trying the selector from there, have it print the elements it returns. Or you can try similar queries on other classes. It could end up being a bug in the way we parse UiSelector expressions. |
I have the same problem with this function!
|
@Jonahss yes,i have try similar queries on other classes,got the same problem |
Hm, to eliminate other sources of error, the next step is to create a regular UiAutomation test, through the usual Android testing method, and see if the same expression works there. |
You might want to try this: |
@wanmich why are you using "+" instead of "? |
try using only UiSelector().className("android.widget.ListView") and get fields like list1.get(index) |
@SrinivasanTarget close this... Inactive thread |
closed ,why? with the following , I get only one element returned. But actually we have 4 elements matched. code = 'new UiSelector().resourceId("io.manong.developerdaily:id/tab_bar").childSelector(new UiSelector().className("android.widget.TextView"))'
eles = driver.find_elements_by_android_uiautomator(code) but only append a 'instance(3)' at the end of java code statment, I get another element matched. code = 'new UiSelector().resourceId("io.manong.developerdaily:id/tab_bar").childSelector(new UiSelector().className("android.widget.TextView").instance(3))'
eles = driver.find_elements_by_android_uiautomator(code) It seems obviously the issue of appium server. |
i have this on java: @AndroidFindBy(uiAutomator = "new UiSelector().resourceId("com.application.activities:id/iconImageView")") products.get(0).click(); |
Confirm see the same thing example is: |
Has anybody been able to tackle this? |
I can confirm this problem still exists in Appium version 1.6.5. |
Still an issue - noticed when using the helper app. Using a selector like this should have returned more than one element (note: 'container_id' matches a single element, while 'another_id' matches multiple)
Returns a single element
Returns 4 elements
Returns 4 elements Tried fromParent thinking that maybe it wouldn't limit the return, but it still doesn't work quite correctly
Returned no elements |
+1 to this bug. It is easily reproducible, provided you have an app with one container element and multiple child elements. |
Due to running out of time and going down a rabbit hole of dealing with some issues with Android and ListView/RecyclerView containers and Appium appium/java-client#150 I took some shortcuts just to get a MVP working as best I could.
I'm seeing the same issue with this in python:
|
Also my workaround for this right now it to use find_element_by_android_uiautomator so I get a UiObject then from that find_elements_by_android_uiautomator:
Which seems to work fine |
@mike-pt @Kignuf If you supply a simple sample app for me to reproduce this issue on, I can hunt it down. A good way of testing would be to take the app and then write a UiAutomator test (rather than Appium) to see if the |
Interesting you said that, cause using the "uiautomatorviewer" (included in appium) the same selector also just picks the first, which means that maybe the issue is in appium not any of the "clients" ? But I can certainly try to import UiAutomator and see how that works, I actually considered it since it seems you can do some cool stuff with |
Oh yeah. It's definitely not an issue with the client. All the clients just send this as text to be interpreted by Appium. |
uiautomatorviewer :

i want to get all the android.widget.RelativeLayout elements which is child of the ListView.
java code:
it only find the first android.widget.RelativeLayout which is child of android.widget.ListView.
appium.log:
and use fromParent can only get the first element:
code:
appium.log
The text was updated successfully, but these errors were encountered: