Android Native App - Cannot locate listView contents. The listView is under FrameLayout

Hi

I am using Appium Server (1.3.4) and java_client 2.2.0. I can’t locate the contents of the a listview which is under framelayout (by xpath)

When I try to locate the frame with by ID, I can find it.

Goal : I want to get the list of all elements in ListView (Visible and Invisible). There might be an issue while getting the invisible elements by using (By ID) but I think hidden elements should be retrievable by using xpath.

Please see attached

When I use to find list view contents by ID, it only returns visible elements.

Platform : Android (Windows), Real device S3 4.4.2

Please advise.

There will be a new version of the Windows GUI out soon. That may resolve this issue since similar problems were fixed in 1.3.5.

Thanks for reply. Would I be able to retrieve all invisible elements under list control after the fix?

I checked with latest Appium server build (1.3.7.1) and xpath seems working fine.

but the xpath is also returning the visible elements on the screen. Any idea to get the full list of elements not in view without scrolling.

Hi umar,

If you are able to locate the element …could you plz share xpath code stuff…

thanks

When you say “invisible” I’m assuming you mean elements that are scrolled out of view, off the screen? From my adventures thus far Android does not support that at all, but iOS does.

So, for Android you will have to code your own functions that scroll the screen hunting for elements, and know when the scrolling has reached the end of the page. It is pretty annoying. :slight_smile: I haven’t completed coding my functions to accomplish this successfully yet, but another user has shared Ruby examples of some functions here: https://discuss.appium.io/t/request-android-find-element-and-scroll-tips

In Android, xpath returns the visible elements on view not the elements which are not in view. So the developer has to implement their own functions and logic to locate, scroll and action on not in view elements.

xpath example:

//android.widget.ListView//descendant::android.widget.RelativeLayout[contains(@resource-id,‘some-text-to-identify’)]

hello all,
i want to click on element in a listview . i am using uiautomatorviewer and Appium v1.6.3 and java client 4.1.2.
driver.findElementByresourceId("//resourceid[@index=‘2’]").click();
but i am not able to click on element in gridview.
appium sever giving this error “contextId: ‘’ multiple: false”.
please help how could i solve this.

That doesn’t look like a valid resource id. uiautomatorviewer should show you what the resource id is.

Given that you are specifying an index, I suspect you are trying to get the 3rd element with the desired resource id. You should be using findElements, and using then choose the element from that list that matches the desired position.

can you please suggest how to select element from a listview.