Yes, same swipe should work. The below code will work irrespective of device screen size because the values are calculated at run time -
/**
* Horizontal swipe Pass : Right2Left to swipe from right to left Pass :
* Left2Right to swipe from left to right
*/
public void swipingHorizontal(String direction) throws InterruptedException {
// Get the size of screen.
size = driver.manage().window().getSize();
log.info(size);
int startx = (int) (size.width * 0.70);
int endx = (int) (size.width * 0.30);
int starty = size.height / 2;
// Swipe from Right to Left.
if (direction.contentEquals("Right2Left")) {
driver.swipe(startx, starty, endx, starty, 3000);
} else if (direction.contentEquals("Left2Right")) {
driver.swipe(endx, starty, startx, starty, 3000);
}
waitFor(2000);
}
/**
* Vertical swipe Pass : Bottom2Top to swipe upwards Pass : Top2Bottom to
* swipe downwards
*/
public void swipingVertical(String direction) throws InterruptedException {
// Get the size of screen.
size = driver.manage().window().getSize();
int starty = (int) (size.height * 0.20);
int endy = (int) (size.height * 0.80);
// int bottom = (int) (size.height);
int startx = size.width / 2;
// Swipe from Bottom to Top.
if (direction.contentEquals("Top2Bottom")) {
driver.swipe(startx, starty, startx, endy, 3000);
} else if (direction.contentEquals("Bottom2Top")) {
driver.swipe(startx, endy, startx, starty, 3000);
}
waitFor(2000);
}