Created
March 10, 2021 21:26
-
-
Save batmi02/183559650000897b17708300b055456a to your computer and use it in GitHub Desktop.
Appium Instructions for Android Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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