Delivered by FeedBurner

Appium Android Example On How To Scroll Down To Text

Earlier In THIS POST, we learnt how to swipe In horizontal or vertical direction In any android software app using driver.swipe() and swiping element in horizontal direction using action chain In previous post. Most of android applications contain list view and you need to scroll down to select specific element. You can use scrollTo(String text) method of IOSElement class If you wants to scroll down till specific text in appium software automation test. Let's try to Implement It practically In android software appium automation test to know how scrollTo(String text) method works.

PREREQUISITES : All previous 21 steps of appium mobile software app automation tutorials (PART 1 and PART 2) should be completed.

Download And Install API Demos App
We will use API Demos In this example. You can download API Demos android software app from GOOGLE PLAY STORE or THIS PAGE. Install It In your mobile device.

Aim To Achieve In This Appium Test
We wants to scroll down till selected element which contains text "Tabs" as shown In bellow Image. And then we wants to tap on It("Tabs" text). Manually you can view bellow given scroll-able listing in API Demos software App from API Demos App -> Views.

So In appium test,
  1. First we will open API Demos App, 
  2. Tap on "Views".
  3. On next screen, Scroll down till element which contain text "Tabs".
  4. And tap on element which contain text "Tabs". 
Create And Run Android Appium scrollTo Text Test
Create file under Android package of your project and copy paste bellow given test script In It.

Note : Please set your device's capabilities in bellow given test.
package Android;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class ScrollingToText {
 AndroidDriver driver;

 public void setUp() throws Exception {
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability("deviceName", "ZX1B32FFXF");
  capabilities.setCapability("browserName", "Android");
  capabilities.setCapability("platformVersion", "4.4.2");
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("appPackage", "");
  driver = new AndroidDriver(new URL(""), capabilities);
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

 public void ScrollToText() throws InterruptedException {
  //Scroll till element which contains "Views" text If It Is not visible on screen.
  // Click on Views/.
  System.out.println("Scrolling has been started to find text -> Tabs.");
  // Scroll till element which contains Tabs text.
  System.out.println("Tabs text has been found and now clicking on It.");
  // Click on Tabs.

 public void End() {

Test Script Description
If you look at above test example, We have used driver.scrollTo(String text) methods for scrolling. It will scroll down steps by step and look If given text Is displayed on screen or not. When text appears, It will stop scrolling.
  • First driver.scrollTo("Views"); will check if element containing test "Views" Is display on screen or not. If not display then It will scroll down down and check for text once again.
  • Same way, Second driver.scrollTo("Tabs"); will scroll down and check for text "Tabs".
To see scrollToText demo practically, Run above test using testng and appium and observe result on your android mobile screen.

This way you can scroll down vertically to find specific element and click on It.


  1. This ScrollTo and ScrollToExact is not working most of the times.Appium scroll beyond the desired element.
    Is there any work around with a perfect solution

  2. ScrollTo and ScrollToExact is of no use, doesn't work at all

  3. Hi,
    ScrollTo method is not working on my Phone and Emulator. I used driver.scrollTo("Tabs"); but nothing happens. Do we need to do some setting on developer options to use it?

    Please suggest!!

  4. hi,
    I want to scroll the page till the end and need to find as scroll reach to the end of page or not , how I can do this. plz reply
    thanks in advance

  5. Hi.. I tried all the possible ways but couldn't find scrollTo(). It gives error "The method scrollTo() is undefined for the type WebDriver"

    Please suggest me something

  6. Hi, I tried all possible ways but couldn't get driver.scrollTo() working. It is giving error "The method scrollTo() is undefined for the type WebDriver".

    Please suggest me how can I add scroll. My app is a hybrid app.

    1. Define your driver as Appium driver in the beginning of your code. scrollTo is a method defined for appium driver.

    2. there is not method in the androidDriver and webdriver.

  7. driver.scrollTo Not working. Showing error message - The method scrollTo(String) is undefined for the type AndroidDriver

  8. Is there any alternate solution as in the new appium release the scrollTo() and scrollToExact() methods have been deprecated.?
    Just want to scroll to a particular element on the android app.

  9. what if scrollTo doesn't get the expected element?? Will it throw an error?

  10. In recent update appium "mobile : scroll" deprecated, following code will work and video will help you to implement.

    Scroll to text :

    MobileElement radioGroup = (MobileElement) wd

    .findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()"


    "new UiSelector().text(\"++\"));");;

    This link will help you :