Appium Android Scroll is not working for ExpandableListView

This piece of code is not working for ExpandableListView.

driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId(\"com.theentertainerme.entertainer:id/ex_listview_locations\")).scrollIntoView(new UiSelector().text(\"Singapore\"))");

There are more indexes than 5, which will be loaded on scroll.

Can someone help?

What error are you receiving?

For debugging, I would verify you get a valid element from driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId(“com.theentertainerme.entertainer:id/ex_listview_locations”)))

Actually, I get a valid element with: driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId(“com.theentertainerme.entertainer:id/ex_listview_locations”)))

but the problem is when appium try to scroll, it scroll down., which results in closing the “ExpandableListView” and hence no element found error is thrown for this .scrollIntoView(new UiSelector().text(“Singapore”)).

Can someone help on how to control scroll for scrolling up first, instead of scrolling down.

Scrolling is difficult to communicate. When you swipe your finger from the bottom of the swipe-able area up to the top, you go further down the list. Did you swipe up or down?

When you say you try to scroll (in some direction), it scrolls down. What are you using to scroll? What do you mean by down? I use the term “scroll to the top” as it unambiguously describes to me what the swipe is doing. If I were searching a list, I’d swipe to the top of the list, then go through the list until I found the desired item.

You have the additional problem that your scrolling closes your expandable list view. Are your scroll coordinates under your control? Can you reduce them to stay within the expandable list view?

If we leave the up/down ambiguity behind, the answers below will help us understand and achieve the goal.:relieved:

Yes thats what I want to achieve, to go through the list until I found the desired item.

`driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().resourceId(\"Id")).scrollIntoView(new UiSelector().text(\"Singapore\"))");`

above mentioned method doesn’t take coordinates. Does it!!! :confused:

Thank you in advance for the interest you are taking to help/solve the problem. :apple:

@hmdarsh, forgive me for some of the questions. I’m using the ruby implementation and because of a recent appium bug, I am was not able to use find_by_uiautomator in our implementation, and we have our own custom scrolling method. Because of those two issues, I’m having to guess at the solution.

Before we switched to Appium 1.6.3, we were scrolling manually using the appium driver’s find_element by uiautomator and we let uiautomator do the scrolling in a similar style to your code: new UiSelector().textMatches("")
So it looks to me like your code should work.

Dimension size  =   driver.manage().window().getSize();
int start_y     =   (int)   (size.height*0.927);
int end_y       =   (int)   (size.height*0.19);
int x           =   size.width / 2;
driver.swipe(x, start_y, x, end_y,1000);

This served the purpose.

Somehow
new UiScrollable(new UiSelector().resourceId(\"com:id/ex_listview_locations\")).scrollIntoView(new UiSelector().text(\"Singapore\"))
Doesn’t work as it should.

hi @willosser
I am unable to use
findelementsbyandroiduiautomator is not available
Can u please tell me what I have missed
I have appium java client 3.1
Selenium standalone jar 2.53.1
So what I have missed

@Abishek, we aren’t using it due to a bug in the implementation when we moved to Appium 1.6.3. I’ve implemented my own scrolling method which takes the coordinates of the element to figure out the swipe command, similar to what @hmdarsh posted above

Hi Abhishek,

I am starting using Appium since 20 days and facing the problem you mentioned.

is that be solved, if so please let me know the solution.

Thank You