Search code examples
androidandroid-espressoandroid-instrumentation

Drag & Drop Espresso


Is it possible to perform drag & drop action via Espresso? I need to move one view down (in straight line) in order to accept some conditions in my automation test.


Solution

  • You can use GeneralSwipeAction to perform drag & drop.

    public static ViewAction swipeUp() {  
    return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER,  
        GeneralLocation.TOP_CENTER, Press.FINGER);  
    }
    

    You can customize the location to meet your requirement as well.