Skip to content

Instantly share code, notes, and snippets.

@batmi02
Created March 10, 2021 21:26
Show Gist options
  • Save batmi02/183559650000897b17708300b055456a to your computer and use it in GitHub Desktop.
Save batmi02/183559650000897b17708300b055456a to your computer and use it in GitHub Desktop.
Appium Instructions for Android Setup
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 900000);
// Session is created using Android Espresso Driver
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ESPRESSO);
capabilities.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir") + "/apps/ApiDemos.apk");
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.findElementByAccessibilityId("Views").click();
// Switch to Android UIAutomator2 from Espresso
Map<String, Object> args = new HashMap<>();
args.put("strategy", "textContains");
args.put("locator", "android.widget.TextView");
args.put("action", "getText");
String text = (String)driver.executeScript("mobile: uiautomator", args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment