---------------------------------------------------------------------------------------------------------- Single tap public static void performSingleTap(AppiumDriverdriver, MobileElement element){ try { TouchActions action = new TouchActions(driver); action.singleTap(element); action.perform(); } catch (Exception e) { Log.fail("Unable to perform Single Tap Operation" + e.getMessage(), driver); } } ------------------------------------------------------------------------------------------------------------ Double tap public static void performDoubleTap(AppiumDriver driver, MobileElement element){ try { TouchActions action = new TouchActions(driver); action.doubleTap(element); action.perform(); } catch (Exception e) { Log.fail("Unable to perform Double Tap Operation" + e.getMessage(), driver); } } ---------------------------------------------------------------------------------------------------------- Perform touch sequence public static void performTouchSequence(AppiumDriver driver, MobileElement element1, MobileElement element2){ try { TouchAction action = new TouchAction(driver); action.press(element1); action.moveTo(element2); action.release(); action.perform(); } catch (Exception e) { Log.fail("Unable to perform Touch Sequence Operation" + e.getMessage()); } } ---------------------------------------------------------------------------------------------------------- Perform multi touch sequence containing different elements public static void performMultiTouch(AppiumDriver driver, MobileElement element1, MobileElement element2,MobileElement element3,MobileElement element4){ try { TouchAction actionOne = new TouchAction(driver); actionOne.press(element1); actionOne.moveTo(element2); actionOne.release(); TouchAction actionTwo = new TouchAction(driver); actionTwo.press(element3); actionTwo.moveTo(element4); actionTwo.release(); MultiTouchAction action = new MultiTouchAction(driver); action.add(actionOne); action.add(actionTwo); action.perform(); } catch (Exception e) { Log.fail("Unable to perform Multi Touch Operation" + e.getMessage(), driver); } } ---------------------------------------------------------------------------------------------------------- Vertical Swipe ( Up and Down) Method 1:- public void verticalScroll(String direction) throws Exception { try { Dimension d = driver.manage().window().getSize(); int x=d.getWidth()/2; int startY; int endY; switch(direction){ case "up": startY = (int) (d.getHeight() * 0.8); endY = (int) (d.getHeight() * 0.2); break; case "down": startY = (int) (d.getHeight() * 0.2); endY = (int) (d.getHeight() * 0.8); break; default: throw new IllegalStateException("Unexpected value: " + direction); } TouchAction touchAction = new TouchAction((AndroidDriver) driver) .press(PointOption.point(x, startY)) .waitAction(WaitOptions.waitOptions(Duration.ofMillis(500))) .moveTo(PointOption.point(x, endY)) .release().perform(); } catch (Exception e) { e.getStackTrace(); } } verticalScroll("up"); verticalScroll("down"); Method 2 : public void scrollVertical(String direction, long duration) throws InterruptedException { try { Dimension size = driver.manage().window().getSize(); int startX = 0; int endX = 0; int startY = 0; int endY = 0; switch (direction){ case "UP": endY= (int) (size.height * 0.70); startY = (int) (size.height * 0.30); startX = (size.width / 2); break; case "DOWN": startY = (int) (size.height * 0.70); endY = (int) (size.height * 0.30); startX = (size.width / 2); break; } new TouchAction(driver) .press(PointOption.point(startX, startY)) .waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration))) .moveTo(PointOption.point(endX, endY)) .release() .perform(); } catch (Exception e) { e.getStackTrace(); } } Method:- scrollVertical("UP",2000); scrollVertical("DOWN",2000); ---------------------------------------------------------------------------------------------------------- Horizontal Swipe ( Right and Left && Left to Right) public void scrollHorizontal(String direction, long duration) throws InterruptedException { try { Dimension size = driver.manage().window().getSize(); int startX = 0; int endX = 0; int startY = 0; int endY = 0; switch (direction){ case "RIGHT": startY = (int) (size.height /2); startX = (int) (size.width * 0.90); endX = (int) (size.width * 0.05); break; case "LEFT": startY = (int) (size.height /2); startX = (int) (size.width * 0.05); endX = (int) (size.width * 0.90); break; } new TouchAction(driver) .press(PointOption.point(startX, startY)) .waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration))) .moveTo(PointOption.point(endX, startY)) .release() .perform(); } catch (Exception e) { e.getStackTrace(); test.log(LogStatus.FAIL, "Something Wrong"); } } Methods:- scrollHorizontal("RIGHT",2000); scrollHorizontal("LEFT",2000);