Appium: How driver.swipe works on ios?
driver.swipe() is an appium method used to swipe on the screen. We can use this method for both Android and IOS.
The general syntax of driver.swipe method is
driver.swipe(int x1, int y1, int x2, int y2, int ms);
(x1, y1) The starting point of swipe
(x2, y2) The end point of swipe
ms In how much time operation should be performed in milliseconds
On Android we simply pass the coordinated of starting and end point but on IOS we pass the relative point of end point.
For example : We want to swipe from point (200,200) to (700,700)
On Android
driver.swipe(200,200,700,700,3000)
On IOS
driver.swipe(200,200,500,500,3000)
Another example for IOS : We want to swipe from point (700,700) to (200,200)
driver.swipe(700, 700, -500, -500, 3000)
Get screen coordinates dynamically
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);
Comments
Post a Comment