简体   繁体   中英

Android Test Case with Appium

Does anyone know how to run Appium Testcase on Windows using Eclipse.

My question is. How Can I run a Test case for an .apk which is already installed on my android device.

Because the sample I am working with, it will install the apk everytime a testcase run.

@Before
public void setUp() throws Exception {

    File appDir = new File("src/Test");
    File app = new File(appDir, "MyTest.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
    capabilities.setCapability(MobileCapabilityType.VERSION, "4.4");
    capabilities.setCapability(MobileCapabilityType.PLATFORM, "Android");
    capabilities.setCapability("app-package", "com.TuneBox.Rokki");
    capabilities.setCapability("app-activity", ".MyTest");

    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}

Ensure that your app installed on the device - otherwise you will receive

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity) (WARNING: The server did not provide any stacktrace information) 

Then just remove MobileCapabilityType.APP capability from your code. Appium will launch the previously installed app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM