Alternative to "mobile: scroll"

Hi all,

While practicing appium i have a requirement to scroll towards right side, for that i am trying “mobile: scroll”

I heard a bug exists at below link.
mobile: scroll not work on Android

Here is what i need:
Lauch api demos ->Views -> Tabs -> 5. Scrollable and then i want to scroll to Tab
8(Which we need to scroll to left to see the Tab 8). How can i do this
in Android. I am trying below, but returning " TypeError: string is not a
function" error message.

Following is the code i am trying:

import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebElement;
import org.testng.annotations.BeforeTest;

import org.testng.annotations.Test;

public class ScrollToExample 
    AndroidDriver driver;
    public void launch()
        DesiredCapabilities capabilities=new DesiredCapabilities();
        capabilities.setCapability("deviceName", "Testing");
        capabilities.setCapability("appPackage", "");
        capabilities.setCapability("appActivity", "ApiDemos");
        driver=new AndroidDriver(new URL(""), capabilities);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    catch(Exception e)

public void ScrollToEle() throws Exception
    driver.findElementByAndroidUIAutomator("text(\"5. Scrollable\")").click();

WebElement tab4=driver.findElementByAndroidUIAutomator("text(\"Tab 4\")");
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "left");
scrollObject.put("element",((RemoteWebElement) tab4).getId());
scrollObject.put("text", ((RemoteWebElement) tab4).getText());
js.executeScript("mobile: scroll", scrollObject);


Following is the error message i am getting after clicking on Scrollable element:

TypeError: string is not a function

Hi @UD

You are passing a string when you should be passing a UISelector function

I believe your call should be

driver.findElementByAndroidUIAutomator("new UiSelector().textMatches(\"5. Scrollable\")").click();

See this link for more detail!topic/appium-discuss/IJgZ7I7-Hyw


Thanks for your reply.

I dont see any problem with my code clicking on “Scrollable” element. After clicking on Scrollable, in next screen, you will see multiple tabs spanning right side. To see the next tabs, you need to scroll left to see next tabs. Here the scrolling is failing.


Could you identify the line of code where your program is failing? Perhaps you can provide the stack trace. Based on the exception message you provided, it appeared your program was failing on the call to findElementByAndroidUIAutomator

Don’t use mobile: scroll on android. Instead use touch actions or UiScrollables. There are examples in the github repo for the java client. There’s even a scrollTo method for Android.


Thanks for pointing me to the right direction. I tried with UIScrollables which was working fine. This helped my purpose.

scrollTo didnt helped me. I am hoping scrollTo looks for the element by scrolling vertical it seems. Correct me if i am wrong.

I am hoping it is hard to use TouchActions in this purpose. Correct me if i am wrong here.

hi @UD,
ScrollTo() will works for horizontal scrolling too…i have done with the same. Please have a try with ScrollTo(“text”);