Swipe Actions
Swipe Vertical on screen:
Create a reusable function and call when required multiple times in test script.
Using size.width size.height and TouchAction
public static void swipeVertical(double startPercentage, double finalPercentage, double anchorPercentage) throws InterruptedException {
Dimension size = driver.manage().window().getSize();
int anchor = (int) (size.width * anchorPercentage);
int startPoint = (int) (size.height * startPercentage);
int endPoint = (int) (size.height * finalPercentage);
new TouchAction(driver).press(anchor, startPoint).moveTo(0, endPoint - startPoint).release().perform();
}To Swipe Vertical, import above function from helper.java class
test.java
$ helper.swipeVertical(0.9, 0.1, 0.5);Swipe Horizontal on screen:
Create a reusable function and call when required multiple times in test script.
Using size.width size.height and TouchAction
To Swipe Horizontal, import above function from helper.java class
Swipe using TouchAction perform of screen:
Create a reusable function and call when required multiple times in test script.
To Swipe using TouchAction perform, import above function from helper.java class
Swipe using Elements of screen:
Create a reusable function and call when required multiple times in test script.
To hide keyboard call below function from helper.java class
Last updated
Was this helpful?