How to swipe vertically in android device? – pCloudy – Question and Answers
Home >> Appium Tricks and Tricks >> How to swipe vertically in android device? ...

How to swipe vertically in android device?


Code Snippet:

//Get the size of screen.
Dimension size = driver.manage().window().getSize();

//Find swipe start and end point from screen’s with and height.
int starty = (int) (size.height * 0.80);

//Find endy point which is at top side of screen.
int endy = (int) (size.height * 0.20);
 
//Find the horizontal point where you want to swipe. It is in middle of screen width.
int startx = size.width / 2;

//Swipe from Bottom to Top.
driver.swipe(startx, starty, startx, endy, 3000);

//Swipe from Top to Bottom.
driver.swipe(startx, endy, startx, starty, 3000);
Note: This code will work for Java client below 6.0.* version.
 

Leave a Reply

Your email address will not be published. Required fields are marked *