Issue with scrollTo and scrollToExact methods of Android Driver. Methods do not scroll to required element text, but scroll to end of page

We are working on a Cordova mobile application. On a screen we have a list of values in a table format. We need to perform a scroll action if we want to select an element not in visible range on the mobile device. The methods scrollTo() and scrollToExact() have been tried but these do not scroll to the required element text, but beyond it, that is to end of values in list.

Moving to native context for performing scroll, had same result.

Also, tried Javascript methods window.scrollTo() and scrollintoView(), but scroll moves past required element.

Is there any other way to achieve scroll to necessary element on mobile screen, such that it does not scroll past the necessary element?

Appium version: 1.3.4.1
Java client version: 2.1.0

1 Like

Hi @sujata_kalluri,

Am also facing the same issue but using Appium 1.3.3 + Python client

Please suggest how to do scrolling in Android using both Python and Java clients

@bootstraponline @jonas @p00j4 @mitsram

Hi @Vallabhaneni_Rakesh,

Above methods did not work for me, so I am using a workaround using below method,
window.scrollBy(0,200).

The operation I wanted was a click, after scrolling to necessary text. There is an attribute on the element that can be checked if click has happened, so I am making use of that in a loop to achieve.

Please check this solution also, if it works. Yet to try this solution.

Code:

js = (JavascriptExecutor) driver;
js.executeScript(“window.scrollTo(0,0)”);
do
{
try
{
driver.findElement(By.xpath().click();
break;
}
catch(Exception e)
{
js = (JavascriptExecutor) driver;
js.executeScript(“window.scrollBy(0, 200)”);

}
} while(true);

Thanks,
Sujata

@Vallabhaneni_Rakesh: scroll is something even I’m looking for a reliable solution for
earlier I could achieve it by swipe [mobile: swipe], but it no longer works since its been replaced with scrollTo etc methods under respective Driver, unfortunately they don’t work for me either.
There are multiple open issues on the same topic. Going through all those open issues might strike any work around for your case until a permanent solution comes.
check this- https://github.com/appium/appium/issues/3974

Hi,
how can we scroll up to particular content using python.
Thanks in advance.

same problem with appium 1.4 + java client 2.2.0

Can you please share the code with which you are trying to perform scroll action

It’s simply
getDriver().scrollTo(account.getAccountName());
where account.getAccountName() returns a string

It’s perfect and should work if getDriver() is AndroidDriver

Hi,
Can you please provide the code snippet. For me it tries to scrolls up instead of down.

Thanks,
Mervin

Please refer below post:

Hi Mitesh,
Thanks for the quick reply.

In my case I want to scroll to particular text and select it. So if I’m using only scrollTo function it scrolls up instead of down.

Can you please help me to achieve it.

Thanks in advance

Hello Dinesh,

In my case,I am using driver.scrollTo(“text to be located”) to scroll and locate the particular text.As soon as I execute this command it’s scroll the whole UI for single time and then goes for locating it.

Also if we need to click the located element then simply use click event with it i.e. driver.scrollTo(“text to be located”).click();

Let me know if you still face the issue.

I tried this , still it scrolls up instead of down.

Don’t know what’s the issue then might be the appium or device issue because in my case it’s working absolutely fine

Thanks for the reply, will try to find the issue and post it here

Same problem with Appium v1.4.0, JavaClient 3.1.0 on real Android device v4.4.

Driver.scrollTo just goes 8 rows down and up again repeating several times. Record I am looking for is on 20th row, so it never gets visible.

1 Like

I have problem with scrolling more than 200 elements in the list. Does anyone have solution for this?

Can you please explain what problem you are facing? Android or iOS ? Little explanation will help

I am testing Android app, scrolling works for list which is having less elements but it is fails to scroll long list say more than 200. When I use scroll function to scroll to element in long list, it scroll up to certain element then it fails saying element couldn’t be found.