Skip to main content

Posts

How to use touch action in Appium

How to use touch action in Appium[Up to date: java-client 6.x.x ] Assuming we have  MobileElement myElement; int xPoint = 282 ; int yPoint = 808 ; int duration = 1000 ; //in milliseconds, change the value as per the required Tap on the Element with element locator(id/xpath): new TouchAction((AndroidDriver) driver ).tap( tapOptions ().withElement( element (myElement))).perform(); Tap on the element with Coordinates: new TouchAction((AndroidDriver) driver ).tap( point (xPoint, yPoint)).perform(); Tap on the Element using coordinates relative to element: new TouchAction((AndroidDriver) driver ).tap( tapOptions ().withElement( element (myElement, xPoint, yPoint))).perform(); LongPress on the Element with element locator(id/xpath) : new TouchAction((AndroidDriver) driver ).longPress( longPressOptions ().withElement( element (myElement))).release().perform(); LongPress on the Element with element locator(id/xpath) and Duration: new TouchAction((AndroidDriver) driver ).longPress
Recent posts

How to capture screenshot during Selenium/Appium test?

How to capture screenshot during Selenium/Appium test? Use following method for getting screenshot during Selenium/Appium test, just create a GetScreenshot.java class and paste the below code. public class GetScreenshot { public static String capture(WebDriver driver, String screenShotName) throws IOException { TakesScreenshot ts = (TakesScreenshot)driver; File source = ts.getScreenshotAs(OutputType. FILE ); String dest = System. getProperty ( "user.dir" ) + " \\ screenshots \\ " + screenShotName + ".png" ; File destination = new File(dest); FileUtils. copyFile (source, destination); return dest; } } Call above method like this: GetScreenshot. capture ( driver , "putScreenshotName" );

How to handle native Android keyboard by using Appium?

How to handle native Android keyboard by using Appium?[ Up to date: java-client 6.x.x ] We are going to tap on the enter button For WebDriver ((AndroidDriver) driver ).pressKey( new KeyEvent(AndroidKey. ENTER )); For AndroidDriver driver .pressKey( new KeyEvent(AndroidKey. ENTER ));   For more KeyEvert please follow the link Android KeyEvent

How to perform Vertical and Horizontal swipe in Appium?

How to perform Vertical and Horizontal swipe in Appium?[ Up to date:  java-client 6.x.x ] In Android application Automation, sometimes we need to scroll up/down and swipe left/right, in this tutorial I'm trying to show how to perform them. 1. For vertical swiping use below method public static void swipeVertical(AppiumDriver driver, double startPercentage, double finalPercentage, double anchorPercentage, int duration) throws Exception { Dimension size = driver.manage().window().getSize(); int anchor = ( int ) (size. width * anchorPercentage); int startPoint = ( int ) (size. height * startPercentage); int endPoint = ( int ) (size. height * finalPercentage); new TouchAction(driver).press(PointOption. point (anchor, startPoint)).waitAction(WaitOptions. waitOptions (Duration. ofMillis (duration))).moveTo(PointOption. point (anchor, endPoint)).release().perform(); } and call the above method like below Scroll up: swipeVertical ((AppiumDriver) dri