How to use AndroidDriver class of io.appium.java_client.android package

Best io.appium code snippet using io.appium.java_client.android.AndroidDriver

BaseAppium.java

Source:BaseAppium.java Github

copy

Full Screen

2import java.io.File;3import java.net.URL;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.remote.DesiredCapabilities;6import io.appium.java_client.android.AndroidDriver;7import io.appium.java_client.remote.MobileCapabilityType;8import io.appium.java_client.service.local.AppiumDriverLocalService;9import io.appium.java_client.service.local.AppiumServiceBuilder;10import mx.AIT.maven.utils.PropertyLoader;11public class BaseAppium {12 public static AppiumDriverLocalService service;13 public static AndroidDriver<WebElement> driver;14 public void init() throws Exception {15 // Carga del fichero de propiedades16 PropertyLoader loadproperty = new PropertyLoader();17 // Recuperación del fichero de propiedades de la ruta y nombre de la aplicación móvil18 String appiumON = System.getProperty("appiumON");19 String device = System.getProperty("device");20 // Generación de las capabilites a nivel del servicio de Appium21 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();22 desiredCapabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);23 // Generación de las capabilites a nivel de driver24 DesiredCapabilities clientCapabilities = new DesiredCapabilities();25 clientCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");26 clientCapabilities.setCapability(MobileCapabilityType.UDID, device);27 clientCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator-5554");28 try {29 if (appiumON.equals("S")) {30 URL url_appium = new URL("http://" + loadproperty.loadProperties().getProperty("AppiumServerIP") + ":" +31 loadproperty.loadProperties().getProperty("AppiumServerPort") + "/wd/hub");32 driver = new AndroidDriver(url_appium, clientCapabilities);33 } else {34 File app = new File(loadproperty.loadProperties().getProperty("apkDir"), loadproperty.loadProperties().getProperty("apkName"));35 desiredCapabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());36 // Appium service37 AppiumServiceBuilder builder = new AppiumServiceBuilder().withCapabilities(desiredCapabilities)38 .withIPAddress(loadproperty.loadProperties().getProperty("AppiumServerIP"))39 .usingPort(Integer.valueOf(loadproperty.loadProperties().getProperty("AppiumServerPort")).intValue());40 service = builder.build();41 service.start();42 driver = new AndroidDriver(service.getUrl(), clientCapabilities);43 }44 } catch (Exception e) {45 throw new Exception ("Error connecting to Appium service : " + e.getMessage());46 }47 }48 public void tearDown() {49 if(driver != null) {50 driver.quit();51 }52 }53}...

Full Screen

Full Screen

DriverUtils.java

Source:DriverUtils.java Github

copy

Full Screen

1package common_utils;2import io.appium.java_client.TouchAction;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidElement;5import io.appium.java_client.remote.MobileCapabilityType;6import io.appium.java_client.touch.TapOptions;7import io.appium.java_client.touch.offset.ElementOption;8import org.openqa.selenium.Platform;9import org.openqa.selenium.remote.DesiredCapabilities;10import java.io.File;11import java.net.MalformedURLException;12import java.net.URL;13import java.util.concurrent.TimeUnit;14public class DriverUtils {15 public static AndroidDriver<AndroidElement> getAndroidDriver(String apkName){16 File apkFile = new File("src/test/resources/apks/" + apkName + ".apk"); // we make it dynamic17 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();18 desiredCapabilities.setPlatform(Platform.ANDROID);19 desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");20 desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "berry");21 desiredCapabilities.setCapability(MobileCapabilityType.APP, apkFile.getAbsolutePath());22 URL serverUrl;23 try {24 serverUrl = new URL("http://localhost:4723/wd/hub");25 }catch (MalformedURLException ex){ // it is a compile time exception so we need to throw the exception26 throw new RuntimeException(ex);27 }28 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(serverUrl, desiredCapabilities);29 return driver;30 }31 public static AndroidDriver<AndroidElement> getAndroidDriver(){32 File apkFile = new File("src/test/resources/apks/ApiDemos-debug-newVersion.apk");33 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();34 desiredCapabilities.setPlatform(Platform.ANDROID); // instated of setCapabilities35 desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "berry");36 desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");37 desiredCapabilities.setCapability(MobileCapabilityType.APP, apkFile.getAbsolutePath());38 URL serverUrl;39 try {40 serverUrl= new URL("http://localhost:4723/wd/hub");41 }catch (MalformedURLException ex){42 throw new RuntimeException(ex);43 }44 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(serverUrl, desiredCapabilities );45 driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);46 return driver;47 }48 public static void tap(AndroidDriver<AndroidElement> driver, AndroidElement targetElement){49 TouchAction touchAction = new TouchAction(driver);50 touchAction.tap(TapOptions.tapOptions().withElement(ElementOption.element(targetElement))).perform();51 }52}

Full Screen

Full Screen

AndInteractionWithKeyboard.java

Source:AndInteractionWithKeyboard.java Github

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import io.appium.java_client.MobileBy;3import io.appium.java_client.TouchAction;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.android.nativekey.AndroidKey;6import io.appium.java_client.android.nativekey.KeyEvent;7import io.appium.java_client.touch.WaitOptions;8import io.appium.java_client.touch.offset.PointOption;9import org.openqa.selenium.By;10import org.openqa.selenium.Dimension;11import org.openqa.selenium.Keys;12import java.time.Duration;13public class AndInteractionWithKeyboard {14 public static void main(String[] args) throws Exception {15 AppiumDriver driver = CreateDriverSession.initializeDriver("Android");16 By views = MobileBy.AccessibilityId("Views");17 By textFields = MobileBy.AccessibilityId("TextFields");18 By editText = MobileBy.id("io.appium.android.apis:id/edit");19 driver.activateApp("io.appium.android.apis");20 Thread.sleep(3000);21 driver.findElement(views).click();22 Dimension size = driver.manage().window().getSize();23 int startX = size.width/2;24 int endX = startX;25 int startY = (int) (size.height*0.8);26 int endY = (int) (size.height*0.2);27 for(int i=0;i<3;i++)28 {29 TouchAction t=new TouchAction(driver);30 t.press(PointOption.point(startX,startY))31 .waitAction(WaitOptions.waitOptions(Duration.ofMillis(2500)))32 .moveTo(PointOption.point(endX, endY))33 .release()34 .perform();35 }36 driver.findElement(textFields).click();37 driver.findElement(editText).sendKeys("QWERTY");38 Thread.sleep(3000);39 System.out.println("Is Keyboard shown : "+((AndroidDriver)driver).isKeyboardShown());40 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.C));41 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.A));42 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.B));43 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.D));44 System.out.println("Is Keyboard shown : "+((AndroidDriver)driver).isKeyboardShown());45 Thread.sleep(2000);46 driver.hideKeyboard();47 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.HOME));48 Thread.sleep(2000);49 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.CALCULATOR));50 Thread.sleep(2000);51 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.CALENDAR));52 driver.getKeyboard().pressKey(Keys.PAGE_DOWN);53 Thread.sleep(2000);54 driver.getKeyboard().pressKey(Keys.HOME);55 }56}...

Full Screen

Full Screen

DriverFactory.java

Source:DriverFactory.java Github

copy

Full Screen

1package Driver;2import caps.MobileCapabilityTypeEx;3import io.appium.java_client.AppiumDriver;4import io.appium.java_client.MobileElement;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.service.local.AppiumDriverLocalService;7import io.appium.java_client.service.local.AppiumServiceBuilder;8import io.appium.java_client.service.local.flags.ServerArgument;9import lesson16.AndroidServerFlagEx;10import org.openqa.selenium.remote.DesiredCapabilities;11import java.io.IOException;12import java.util.Locale;13import java.util.concurrent.TimeUnit;14public class DriverFactory {15 private static AppiumDriverLocalService appiumServer;16 private static AndroidDriver<MobileElement> androidDriver;17 public static void startAppiumServer (){18 AppiumServiceBuilder appiumServiceBuilder = new AppiumServiceBuilder();19 appiumServiceBuilder.withArgument(AndroidServerFlagEx.ALLOW_INSECURE, "chromedriver_autodownload");20 appiumServiceBuilder.withIPAddress("127.0.0.1").usingAnyFreePort();21 appiumServer = AppiumDriverLocalService.buildService(appiumServiceBuilder);22 appiumServer.start();23 }24 public static void stopAppiumServer (){25// String killNodeWindowsCmd = "taskkill /F /IM node.exe";26// String killNodeLinuxCmd = "killall node";27// String currentOS = System.getProperty("os.name").toLowerCase();28// String killNodeCmd = currentOS.startsWith("windows") ? killNodeWindowsCmd : killNodeLinuxCmd;29// Runtime runtime = Runtime.getRuntime();30// try{31// runtime.exec(killNodeCmd);32// } catch (IOException e){33// e.printStackTrace();34// }35 }36 public static AndroidDriver<MobileElement> getAndroidDriver(){37 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();38 desiredCapabilities.setCapability(MobileCapabilityTypeEx.PLATFORM_NAME, "Android");39 desiredCapabilities.setCapability(MobileCapabilityTypeEx.AUTOMATION_NAME, "uiautomator2");40 desiredCapabilities.setCapability(MobileCapabilityTypeEx.UDID, "NFDIVKMV99999999");41 desiredCapabilities.setCapability(MobileCapabilityTypeEx.APP_PACKAGE, "com.wdiodemoapp");42 desiredCapabilities.setCapability(MobileCapabilityTypeEx.APP_ACTIVITY, "com.wdiodemoapp.MainActivity");43 desiredCapabilities.setCapability(MobileCapabilityTypeEx.NEW_COMMAND_TIMEOUT, 120);44 androidDriver = new AndroidDriver<>(appiumServer.getUrl(), desiredCapabilities);45 androidDriver.manage().timeouts().implicitlyWait(1L, TimeUnit.SECONDS);46 return androidDriver;47 }48}...

Full Screen

Full Screen

AndInteractWithKeyboard.java

Source:AndInteractWithKeyboard.java Github

copy

Full Screen

1package com.appium;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileBy;4import io.appium.java_client.TouchAction;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.android.nativekey.AndroidKey;7import io.appium.java_client.android.nativekey.KeyEvent;8import io.appium.java_client.touch.WaitOptions;9import io.appium.java_client.touch.offset.PointOption;10import org.openqa.selenium.By;11import org.openqa.selenium.Dimension;12import org.openqa.selenium.Keys;13import java.time.Duration;14import java.util.concurrent.TimeUnit;15public class AndInteractWithKeyboard {16 public static void main(String[] args) throws Exception {17 AppiumDriver driver = CreateDriverSession.initializeDriver("Android");18 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);19 By views = MobileBy.AccessibilityId("Views");20 By textFields = MobileBy.AccessibilityId("TextFields");21 By editText = MobileBy.id("io.appium.android.apis:id/edit");22 driver.findElement(views).click();23 Dimension size = driver.manage().window().getSize();24 int startX = size.width / 2;25 int endX = startX;26 int startY = (int) (size.height * 0.8);27 int endY = (int) (size.height * 0.2);28 for(int i=0;i<3;i++){29 TouchAction t = new TouchAction(driver);30 t.press(PointOption.point(startX, startY))31 .waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))32 .moveTo(PointOption.point(endX, endY))33 .release()34 .perform();35 }36 driver.findElement(textFields).click();37 driver.findElement(editText).click();38 Thread.sleep(3000);39 System.out.println(((AndroidDriver) driver).isKeyboardShown());40 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.C));41 driver.getKeyboard().pressKey(Keys.ARROW_DOWN);42 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.HOME));43 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.CALENDAR));44 ((AndroidDriver) driver).pressKey(new KeyEvent().withKey(AndroidKey.B));45 Thread.sleep(3000);46 driver.getKeyboard().pressKey(Keys.HOME);47 // driver.hideKeyboard();48 }49}...

Full Screen

Full Screen

BasePage.java

Source:BasePage.java Github

copy

Full Screen

1package Pages;2import io.appium.java_client.TouchAction;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidElement;5import io.appium.java_client.pagefactory.AndroidFindBy;6import io.appium.java_client.pagefactory.AppiumFieldDecorator;7import io.appium.java_client.touch.offset.PointOption;8import org.openqa.selenium.By;9import org.openqa.selenium.support.PageFactory;10import org.openqa.selenium.support.ui.ExpectedConditions;11import org.openqa.selenium.support.ui.WebDriverWait;12import java.time.Duration;13public class BasePage {14 protected AndroidDriver androidDriver;15 protected static WebDriverWait wait;16 public BasePage(AndroidDriver androidDriver){17 this.androidDriver = androidDriver;18 wait = new WebDriverWait(androidDriver,6);19 PageFactory.initElements(new AppiumFieldDecorator(androidDriver),this);20 }21 @AndroidFindBy (xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.LinearLayout[1]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageButton")22 AndroidElement BurgerMenu;23 @AndroidFindBy (xpath = "//android.widget.CheckedTextView[@text='The Buzz!']")24 AndroidElement BuzzTab;25 public void OpenBurgerMenu(){26 wait.until(ExpectedConditions.visibilityOf(BurgerMenu));27 BurgerMenu.click();28 }29 public void ScrollDown(){30 wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("com.jelvix.crowdthinc:id/titleTextView")));...

Full Screen

Full Screen

Capability.java

Source:Capability.java Github

copy

Full Screen

1package demos;2import java.net.MalformedURLException;3import java.net.URL;4import org.openqa.selenium.remote.DesiredCapabilities;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.android.AndroidElement;7import io.appium.java_client.remote.AndroidMobileCapabilityType;8import io.appium.java_client.remote.AutomationName;9import io.appium.java_client.remote.MobileCapabilityType;10public class Capability {11 public static AndroidDriver<AndroidElement> capabilities() throws MalformedURLException 12 {13 DesiredCapabilities cap = new DesiredCapabilities();14 15 cap.setCapability(MobileCapabilityType.DEVICE_NAME, "linto");16 cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");17 cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);18 cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.androidsample.generalstore");19 cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.androidsample.generalstore.SplashActivity");20 cap.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, "C:\\Users\\LintoThomas\\Desktop\\Linto Archive W10\\Automation\\chromedriver.exe");21 AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://0.0.0.0:4723/wd/hub"),cap);22 return driver;23 //Second commit 324 25 }26}...

Full Screen

Full Screen

DriverAndroid.java

Source:DriverAndroid.java Github

copy

Full Screen

1package GerenciadorDriver;2import io.appium.java_client.AppiumDriver;3import io.appium.java_client.MobileElement;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.remote.AndroidMobileCapabilityType;6import io.appium.java_client.remote.MobileCapabilityType;7import org.openqa.selenium.Capabilities;8import org.openqa.selenium.remote.DesiredCapabilities;9import java.net.MalformedURLException;10import java.net.URL;11public class DriverAndroid {12 //static AppiumDriver<MobileElement> driver;13 static AndroidDriver driver;14 public static Capabilities configuracaoEmulador() throws MalformedURLException {15 DesiredCapabilities capabilities = new DesiredCapabilities();16 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"android");17 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"emulator-5554");18 capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"uiautomator2");19 capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"com.leavjenn.hews.ui.MainActivity");20 driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);21 return capabilities;22 }23 public static AndroidDriver getDriver(){24 return driver;25 }26}...

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.android.AndroidDriver;2import org.openqa.selenium.remote.DesiredCapabilities;3import java.net.URL;4import java.net.MalformedURLException;5public class appium {6public static void main(String[] args) throws MalformedURLException {7DesiredCapabilities capabilities = new DesiredCapabilities();8capabilities.setCapability("deviceName", "My Phone");9capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");10capabilities.setCapability(CapabilityType.VERSION, "4.4.2");11capabilities.setCapability("platformName", "Android");12capabilities.setCapability("appPackage", "com.android.calculator2");13capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1package appium;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.concurrent.TimeUnit;5import org.openqa.selenium.By;6import org.openqa.selenium.remote.CapabilityType;7import org.openqa.selenium.remote.DesiredCapabilities;8import io.appium.java_client.android.AndroidDriver;9public class AppiumTest {10public static void main(String[] args) throws MalformedURLException, InterruptedException {11 DesiredCapabilities capabilities = new DesiredCapabilities();12 capabilities.setCapability(CapabilityType.BROWSER_NAME, "");13 capabilities.setCapability("deviceName", "Android Emulator");14 capabilities.setCapability("platformVersion", "4.4");15 capabilities.setCapability("platformName", "Android");16 capabilities.setCapability("appPackage", "com.android.calculator2");17 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.android.AndroidDriver;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.android.AndroidDriver;7import io.appium.java_client.android.AndroidDriver;8import io.appium.java_client.android.AndroidDriver;9import io.appium.java_client.android.AndroidDriver;10import io.appium

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1package appium.java;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidElement;4import java.net.MalformedURLException;5import java.net.URL;6import org.openqa.selenium.remote.DesiredCapabilities;7public class appium.java {8public static void main(String[] args) throws MalformedURLException {9DesiredCapabilities cap = new DesiredCapabilities();10cap.setCapability("deviceName", "Android device");11cap.setCapability("udid", "emulator-5554");12cap.setCapability("platformName", "Android");13cap.setCapability("platformVersion", "10");14cap.setCapability("appPackage", "com.android.calculator2");15cap.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1import java.net.URL;2import java.net.MalformedURLException;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.remote.CapabilityType;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.Keys;8import org.openqa.selenium.TimeoutException;9import org.openqa.selenium.WebDriver;10import org.openqa.selenium.support.ui.WebDriverWait;11import org.openqa.selenium.support.ui.ExpectedConditions;12import org.openqa.selenium.support.ui.ExpectedCondition;13import org.openqa.selenium.support.ui.FluentWait;14import org.openqa.selenium.support.ui.Wait;15import org.openqa.selenium.support.ui.Select;16import org.openqa.selenium.support.PageFactory;17import org.openqa.selenium.JavascriptExecutor;18import org.openqa.selenium.TakesScreenshot;19import org.openqa.selenium.OutputType;20import org.openqa.selenium.ScreenOrientation;21import org.openqa.selenium.Dimension;22import org.openqa.selenium.Point;23import org.openqa.selenium.Alert;24import org.openqa.selenium.NoAlertPresentException;25import org.openqa.selenium.NoSuchElementException;26import org.openqa.selenium.StaleElementReferenceException;27import org.openqa.selenium.UnhandledAlertException;28import org.openqa.selenium.WebDriverException;29import org.openqa.selenium.remote.RemoteWebDriver;30import org.openqa.selenium.remote.RemoteWebElement;31import org.openqa.selenium.remote.CommandExecutor;32import org.openqa.selenium.remote.Command;33import org.openqa.selenium.remote.Response;34import org.openqa.selenium.remote.SessionId;35import org.openqa.selenium.remote.Augmenter;36import org.openqa.selenium.remote.CapabilityType;37import org.openqa.selenium.remote.DesiredCapabilities;38import org.openqa.selenium.remote.ErrorHandler;39import org.openqa.selenium.remote.HttpCommandExecutor;40import org.openqa.selenium.remote.RemoteTouchScreen;41import org.openqa.selenium.remote.RemoteWebDriver;42import org.openqa.selenium.remote.SessionNotFoundException;43import org.openqa.selenium.remote.UnreachableBrowserException;44import org.openqa.selenium.remote

Full Screen

Full Screen

AndroidDriver

Using AI Code Generation

copy

Full Screen

1package com.appium;2import java.net.MalformedURLException;3import java.net.URL;4import org.openqa.selenium.remote.DesiredCapabilities;5import io.appium.java_client.android.AndroidDriver;6import io.appium.java_client.remote.MobileCapabilityType;7public class Appium {8public static void main(String[] args) throws MalformedURLException {9 DesiredCapabilities cap = new DesiredCapabilities();10 cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");11 cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");12 cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.1.0");13 cap.setCapability("appPackage", "com.android.calculator2");14 cap.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful