If (eSwipeDirection = SwipeDirections.DOWN) //swipe down TouchAction tAction = new TouchAction(AppiumDriver.Instance) Public static void Swipe(SwipeDirections eSwipeDirection) driver.findElement(By.name("YourText")).click() Int scrollEnd = Convert.ToInt32(screenHeightEnd) įor (int i = 0 i < Convert.ToInt32(scrollCounter) i++)Ī(0, scrollStart, 0, scrollEnd, 2000) Int scrollStart = Convert.ToInt32(screenHeightStart) dimensions = ().Window.Size ĭouble screenHeightStart = dimensions.Height * 0.5 ĭouble screenHeightEnd = dimensions.Height * 0.2 Js.ExecuteScript("window.scrollBy(0," + ScrollAmount + ")") Ī = "NATIVE_APP" IJavaScriptExecutor js = (IJavaScriptExecutor)AppiumDriver.Instance Public static void Scroll(int ScrollAmount)ĭouble scrollCounter = ScrollAmount / 100 Here are the sample code snippet’s for different gestures. Js.executeScript("mobile: scroll", scrollObject) JavascriptExecutor js = (JavascriptExecutor) driver You can write your own parallel code to perform scroll and here is the code snippet for the same. The project would help you learn how to automate android app using Appium.Īppium let’s you do a scroll to the element text but sometimes it might not work depending on how app is and CSS structure are. We have added some test in the git project to show how to use the gestures in automation. It implements actions for touch devices and basically built upon the Actions class. You might also want to explore TouchActions class provided by Selenium. Prefix “ mobile:” allows us to route these requests to the appropriate endpoint. Some of the mobile methods to be used are: mobile: tap Duration basically specifies how long it will tap and is in seconds. So in above example it means, 1% from x and 50% from y coordinates. When we enter the coordinates in decimal, it actually specifies the percentage. Js.executeScript(“mobile: swipe”, swipeObject) SwipeObject.put(“duration”, 3.0) //Tap 3 secs Sample code would look like as: JavascriptExecutor js = (JavascriptExecutor) driver We can pass in coordinates as parameters and specify the action we want. TouchAction class is available from namespace Apart from that they have also enabled JSON wire protocol server extensions. It’s more like Actions class in Selenium. Some of the common gestures are:Īppium handles these gestures using TouchActions api they have created. With lot of unique gesture supported on mobile devices, automation has its own challenge. Gestures play an important role in how your app is being used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |