Search code examples
javaandroidappiumswipe

Swipe gesture is very slow,...how to speed up my Swipe Gesture in android?


I have horizontal swipe gesture for my Appium test but when it is executed to the swipe gesture is very slow. Is there any posible way to do it? Suggestion will be really appreciated.

i already add some waitAction() but it does not help

  public void horizontalSwipeRightToLeft(AndroidDriver driver){
        Dimension deviceDim = driver.manage().window().getSize();
        int height = deviceDim.getHeight();
        int width = deviceDim.getWidth();
        int y = (int) (height*0.20);
        int startX = (int) (width*0.80);
        int endX = (int) (width*0.20);
        TouchAction swipe = new TouchAction(driver);
        swipe.longPress(point(startX,y))
                .moveTo(point(endX,y)).release()
                .perform();
    }

and i also try this code but its the same output as you can see i added some duration..

TouchAction swipe = new TouchAction(driver);
        swipe.longPress(LongPressOptions.longPressOptions()
                .withPosition(point(startX,y))
                .withDuration(Duration.ofMillis(250)))
                .moveTo(point(endX,y)).release()
                .waitAction(WaitOptions.waitOptions(Duration.ofMillis(100)))
                .perform();

Solution

  • There are alternative approaches to perform swipe/scroll:

    1. Using mobile:shell command like:

      Map<String, Object> args = new HashMap<>();
      args.put("command", "input");
      args.put("args", Lists.newArrayList("swipe", "startX","startY","endX","endY"));
      driver.executeScript("mobile: shell", args);
      
    2. Using Swipe command available via SeeTest Appium Extension like:

      seetest.swipe("Right", 10, 500);