Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Appium test script
@Test
public void addPerson_Successfully() throws MalformedURLException {
File app = new File("src/main/resources/app/workshop.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.eliasnogueira.workshop");
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "activities.ListActivity");
AndroidDriver<MobileElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("com.eliasnogueira.workshop:id/fab")));
driver.findElement(By.id("com.eliasnogueira.workshop:id/fab")).click();
driver.findElement(By.id("com.eliasnogueira.workshop:id/txt_nome")).sendKeys("Jon Snow");
driver.findElement(By.id("com.eliasnogueira.workshop:id/txt_endereco")).sendKeys("The wall");
driver.findElement(By.id("com.eliasnogueira.workshop:id/txt_hobbies")).sendKeys("Know nothing");
driver.findElement(By.id("com.eliasnogueira.workshop:id/button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("android:id/search_button")));
driver.findElement(By.id("android:id/search_button")).click();
driver.findElement(By.id("android:id/search_src_text")).sendKeys("Jon Snow");
String text = driver.findElement(By.id("android:id/text1")).getText();
assertEquals("Jon Snow", text);
driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.