Automate swipe using appium – use of TouchAction


Swipe on mobile handsets can be of from

  • Left to right or vice versa
  • Top to bottom or vice versa

Let’s see how we can automate swipe in appium.



Depending on appium version you are using, implementation defers


On java-client 6.0 onwards, we have use PointOptions.point() to assign coordinates and WaitOptions.waitOptions() to assign duration


For Appium Java-Client version 5.0.0 onwards, Swipe() deprecated, alternate solution is to use class TouchAction


For Appium java-client version less than 5.0.0, use swipe() method


Start location (x and y axis location) to end location (x and y axis location) and the duration of swipe action.

E.g – If want to move from left to right, change the startx and starty values, but keep constant for startY and endY values.

We will be using Phone application, where we will be swiping from right to left to move Favorites to Call history.

NOTE: Always better to get the width and height of the panel on which we want to swipe rather than hard coding the x and y axis values, as it gets changes from one device to another.


Watch the details here –




For appium java-client version <= 5.0.0, follow below code


Explanation of the above code – refer below screenshot

Starting position – we have taken somewhere half of the way of the panel on which we need to swipe.


Reference – Appium API documentation

Shortlink –

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

8 Responses

  1. pratheep says:

    not working

  2. sunilpatro1985 says:

    what error u r getting, can I see ur code block and application u r working?

  3. Raghavendra says:

    Hi Sunil,

    I have a watermark in my application and i want to scroll till that watermark, but when i run the code it says unable to find the element can you please hlep me in this regard


  4. sunilpatro1985 says:

    Hi Raghvendra,

    Follow and retry, or share your app details so I can take a look.

  5. Raghavendra says:


    This code scrolls till the specified time in swipe method, please let me know how to swipe to specific element in the screen (Ex: if there is a element called password in the screen, i want to swipe till password)

  6. Arun says:

    Getting error Original error: Cannot start the ‘’ application.
    Unable to start from Appium also, but able to start from Cmd using “adb shell am start -n”

    javaclient 6.1.0
    java jdk1.8.0_144
    Appium server 1.9.1

    • sunilpatro1985 says:

      is you appium server is running before running the tests?
      and the appActivity is

Leave a Reply

Your email address will not be published. Required fields are marked *