2015-05-28 95 views
1

有誰知道如何使用Eclipse在Windows上運行Appium Testcase。Android測試用例與Appium

我的問題是。我怎樣才能運行我的Android設備上已經安裝的.apk的測試用例。

因爲我正在使用的示例,它會在每次運行測試用例時安裝apk。

@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); 

} 

回答

0

確保在設備上安裝您的應用程序 - 否則,你將收到

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) 

然後,只需從你的代碼中刪除MobileCapabilityType.APP能力。 Appium將推出先前安裝的應用程序。

相關問題