我正在尝试使用maven android插件创建我正在使用Appium在Saucelabs上自动运行集成测试的Android应用程序。到目前为止我尝试的所有内容都只给了我错误"无法下载移动应用程序:c:\ workspace \ android \ android-it .. \ android-app \ target \ android-app.apk"
我正在使用以下配置的集成测试pom文件中使用sauceconnect:
<plugins>
<plugin>
<groupId>com.saucelabs.maven.plugin</groupId>
<artifactId>sauce-connect-plugin</artifactId>
<version>1.0.15</version>
<configuration>
<sauceUsername>MY USERNAME</sauceUsername>
<sauceAccessKey>MY KEY</sauceAccessKey>
</configuration>
<executions>
<!-- Start Sauce Connect prior to running the integration tests -->
<execution>
<id>start-sauceconnct</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-sauceconnect</goal>
</goals>
</execution>
<!-- Stop the Sauce Connect process after the integration tests have finished -->
<execution>
<id>stop-sauceconnect</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-sauceconnect</goal>
</goals>
</execution>
</executions>
</plugin>
我的appium测试的配置是在我的设置方法中完成的,如下所示:
@Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File app = new File(classpathRoot, "../android-app/target/android-app.apk");
logger.info("PATH");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("apk", "sauce-storage:my_app.apk");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("deviceType", "phone");
capabilities.setCapability("device","Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app-package", "com.android-app");
capabilities.setCapability("app-activity", ".MainActivity");
capabilities.setCapability("takesScreenshot", true);
driver = new RemoteWebDriver(
new URL("http://user:key@ondemand.saucelabs.com:80/wd/hub"),
capabilities);
// driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
根据我在Saucelabs和Appium上阅读的所有内容,这应该允许我的apk正确下载并在我运行maven版本时运行,但是,如上所述,这似乎不是案子。如果有人可以向我提供我所缺少的内容,我将非常感激。
答案 0 :(得分:0)
您正尝试使用本地应用路径启动Sauce会话;由于Sauce无法访问该路径,因此无法从中下载APK。
我假设您是manually uploading您的应用,或者您的Maven配置在每次构建之前都这样做。 (额外提示:确保传递overwrite
参数,并将其设置为true!)
如果您将'app'功能设置为您用于'apk'功能(Sauce Storage参考)的值,那么您的测试应该能够下载您的应用。作为一方,我不确定你的测试使用的'apk'功能来自哪里;在Sauce Labs / Appium文档中引用了哪些内容?
您也不再需要Appium 1.0的app-package
或app-activity
功能。
尝试以下功能:
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("deviceType", "phone");
capabilities.setCapability("app", "sauce-storage:my_app.apk");
capabilities.setCapability("takesScreenshot", true);