Long Press on Element using Appium

Let’s see, How can you perform Long press on Element using Appium in Andriod App Testing. In previous tutorials, You have seen, How can you Set the Rating in Android using Appium. Now we will see, How can we perform Long Press on Element using Appium in Andriod Application.

 

In Many Andriod Applications, Sometimes you need to press and hold(long press) an element for few seconds to get required result. To perform this programmatically, We can use TochAction class in Appium.

 

Long Press on Element using Appium

In TouchAction class, We have longPress(Element el) method to perform the LongPress in Android.

Let’s take an Example, Suppose in your Application, You have some data which you want to delete, And you will get the Delete option once you longpress this element. So for this, you need to longPress your target Element then find the ID of Delete element and click Delete button.

 

Let’s implement the above code.

In above example, We have implemented the logic to long press the element and delete it.

 

Using this way you can perform longpress on any element of your Android Application.

0 Comment

Leave a Reply