package testProject; import org.openqa.selenium.*; import org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import java.net.MalformedURLException; import java.net.URL; import org.testng.annotations.Test; //import org.testng.annotations.BeforeClass; //import org.testng.annotations.AfterClass; import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import java.net.URL; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; @SuppressWarnings("unused") public class AppiumDemo{ public static void main(String[] args) throws MalformedURLException, InterruptedException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "20dfa4c5"); //capabilities.setCapability("deviceName", "Android Emulator"); capabilities.setCapability("automationName", "Appium"); capabilities.setCapability("platformName", "Android"); //capabilities.setCapability("platformVersion", "6.0"); capabilities.setCapability("platformVersion", "6.0.1"); capabilities.setCapability("appPackage", "com.sec.android.app.popupcalculator"); capabilities.setCapability("appActivity", "com.sec.android.app.popupcalculator.Calculator"); //capabilities.setCapability("appPackage", "com.android.calculator2"); //capabilities.setCapability("appActivity", ".Calculator"); @SuppressWarnings("rawtypes") AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.findElement(By.name("1")).click(); driver.findElement(By.name("5")).click(); driver.findElement(By.name("9")).click(); //driver.findElement(By.name("delete")).click(); driver.findElement(By.id("bt_backspace")).click(); driver.findElement(By.id("bt_add")).click(); driver.findElement(By.name("6")).click(); driver.findElement(By.name("=")).click(); driver.findElement(By.id("history_button")).click(); driver.findElement(By.name("=")).click(); //driver.findElement(By.id("bt_00")).click(); Thread.sleep(2000); String result = driver.findElement(By.id("com.sec.android.app.popupcalculator:id/txtCalc")).getText(); System.out.println(result); driver.quit(); } }