How to Swipe Right on the Element?
Posted on October 3, 2019
By Shibu Panda
public void swipeRightOnElement(WebElement element) {
Point point = element.getLocation();
Dimension eleSize = element.getSize();
int centerX = point.getX() + (eleSize.getWidth() / 2);
int centerY = point.getY() + (eleSize.getHeight() / 2);
int moveToX = point.getX() + (eleSize.getWidth());
int moveToY = point.getY() + (eleSize.getHeight() / 2);
new TouchAction(driver)
.press(PointOption.point(centerX,centerY))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
.moveTo(PointOption.point(moveToX, moveToY))
.release().perform();
}