Drag and Drop in Appium

Let’s see Drag and Drop in Appium. In previous tutorials, You have seen, How can you find the elements in Appium. In this tutorial, You will see how can you manage the Drop-Down in Appium.


Drag And Drop Is one of the common action of any android app. In Android Automation where you have to perform drag and drop then you need to use TouchAction class.


Drag and Drop in Appium

TouchAction class provides us the facility to automate mobile gestures of the Android app using Appium.

Let’s take the very simple example to perform drag and drop operation on Android Application using Appium.


Suppose we have an Application, On which we need to perform Drop & Drag operation. Let’s understand this using the example of simple code.

Let me describe you few Important class and methods which are used in above test script.

    • TouchAction : This is the class of Webdriver, Which provide different methods(longPress, moveTo, perform, press, tap, etc..) to automate mobile gestures like drag and drop, swipe etc.

    • longPress : longPress is a method to hold tap for a long time on given element.

    • moveTo : moveTo is a method to move action.

    • release : release is used to release from longPress tap action.

    • perform : perform will execute full action chain of drag and drop.



    Please note in above test script, We have used AndroidDriver at place ofRemoteWebDriver as we are automating android app.

    And also used findElementByName(“”) and findElementsById(“”) methods at place of findElement(By.Name(“”)) and findElements(By.Id(“”)) methods.


    Run above test using TestNG and observe Drag And Drop in your mobile device.

    • It will launch App.

    • Tap on First Element text and

    • Perform drag and drop operation.


    This way we can automate mobile gestures in Appium Android Automation test.

    0 Comment

    Leave a Reply