I need to scroll vertically (up and down) and horizontally (left and right) using appium + selenium + java. Can anyone please help me with snippet of the code required for this with explanation so I can use it further in other projects.
To Swipe right to left use below code
Dimension size = driver.manage().window().getSize();
int startx = (int) (size.width * 0.8);
int endx = (int) (size.width * 0.20);
int starty = size.height / 2;
driver.swipe(startx, starty, endx, starty, 1000);
left to right : the direction simply change start-x to end-x and end-x to startx
To swipe up/down : x-axis co-ordinates will remain same only y-coordinates will change.
If you are curious to know more about co-ordinates then turn on "Pointer location" setting from "Developer options" and observe co-ordinates manually.