Skip to content

Instantly share code, notes, and snippets.

Last active March 12, 2021 01:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dannyshain/c6eba96dcee3382837a808b406833f65 to your computer and use it in GitHub Desktop.
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(""), capabilities);
// 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