Skip to main content

Posts

Showing posts from September, 2018

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

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