Sunday 2 October 2016

How to Perfrom Vertical Scroll without using scrollTo() in Appium ?

I have already written How To Perform Vertical Scroll using scrollTo()? But if you have updated with new Java Client 4.1.2 then you will notice that scrollTo() method is deprecated. So In this post I am going to explain an alternative way to perform Vertical Scroll. It is very simple and easy to understand hence lets begin.

Test Case Scenario -

1. Launch the application
2. Perform vertical scroll

Finding X-Coordinate -
We need y co-ordinates of the screen  and to find that there are two ways -
1. Using Pointer Location-
    * Go to phones Settings
    * Click on Developer Options
    * Enable Pointer Location 
    * open your app and click on the mid of the horizontal tab and then you will get x and y
       coordinates but note down x- coordinates.

2. Using UI automator - 
   *Open UIAutomator Inspector.
   * Take screen shot.
   * Click on middle of the horizontal tab and note down x-coordinates displayed at top right corner.

Test Case -
1. We will implement verticalScroll() method. In this method we will get the screen size with that we can find our start point and end point as we are going o scroll. We also have x co-ordinates so we can use driver.swipe() to perform vertical scroll as shown below
2. We are using for loop to scroll till we find the expected text.

    public void testScroll()throws Exception
        for(int i=0;i<4;i++)
            if (driver.findElement("end_item")).isDisplayed())

    public void verticalScroll()
        int y_start=(int)(size.height*0.60);
        int y_end=(int)(size.height*0.30);
        int x= size.width / 2;

with this post you can write test code for Vertical Scroll up to specified dimensions , Vertical Scroll till you find the element  and vertical scroll till the end.

I hope you find this tutorial useful. Do share your feedback and questions in comments section below.Please follow me on social media to get latest post updates.


  1. im using programmatic way of starting appium do i start appium 1.5+ programmatically..and i havent installed appium.exe

  2. [debug] Display bounds: [0,0][720,1280]
    info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][720,1280]
    info: [debug] [BOOTSTRAP] [debug] Swiping from [x=360.0, y=768.0] to [x=360.0, y=384.0] with steps: 112

    but it doesnt scrolls

  3. obsolete way.

  4. Hi,
    I have scenario like this. I do a search and app displays search result in list format. Now i want to get count of all the elements in the list. getsize() methods gives count of only visible items. but there will be still many elements which will be invisible(i.e page needs to be scrolled). So how can i get total count(both visible and invisble) of elements

  5. Why do we need to multiply height and width into some percentage like it is done in the above example (size.height*0.60). How do we know what exact percentage we have to multiple it to? I'm always confused getting correct coordinates. Please share the solution.

  6. The Collection Marts is platform where you can view latest designs about home d├ęcor and bedding. We have large range in different categories with finest fabric in cotton and silk. You can view not only present trends but also view huge collection with reasonable price. new bed sheet , double bed comforter , gul ahmed comforter price , fancy bed sheets designs , duvet sets The Collection Marts can provide fast service about delivery as well as customer support too. Our products are not only self-made but also, well connected with markets to ensure for possibility of available designs if client want to purchase. The Collection Marts customer support open 24/7 to guide their customers about material or product stuff.