我正在使用Linux,我想使用Appium编写测试。目前我安装了所有必需的工具来运行它(Node不是通过brew安装节点安装,而是使用nvm安装节点)。 Appium在localhost上运行(欢迎使用Appium v1.4.6信息:Appium REST http接口监听器在0.0.0.0:4723上启动信息:Console LogLevel:debug)
我的代码: 公共类MyTestApp {
private AppiumDriver<AndroidElement> driver;
@Test
public void mytestapptest () throws MalformedURLException {
File file = new File("/home/kacinauskasl/workspace/appiumTests/AppiumProject/apk/myapk.apk");
DesiredCapabilities capability = new DesiredCapabilities();
capability.setCapability("deviceName", "HTC");
capability.setCapability("platformName", "Android");
capability.setCapability("platformVersion", "5.0.2");
capability.setCapability("app", file.getAbsolutePath());
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capability);
}
}
当我通过TestNG或Junit运行时,我收到错误:
warn: W/zipro ( 7260): Error opening archive /home/kacinauskasl/workspace/appiumTests/AppiummProject/apk/myapk.apk: Invalid file
ERROR: dump failed because assets could not be loaded
error: Problem parsing package and activity from manifest: Error: packageAndLaunchActivityFromManifest failed. Error: Command failed: /bin/sh -c /home/kacinauskasl/SDK/android-sdk-linux/build-tools/23.0.0-preview/aapt dump badging /home/kacinauskasl/workspace/appiumTests/AppiummProject/apk/myapk.apk
W/zipro ( 7260): Error opening archive /home/kacinauskasl/workspace/appiumTests/AppiummProject/apk/myapk.apk: Invalid file
ERROR: dump failed because assets could not be loaded
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: packageAndLaunchActivityFromManifest failed. Error: Command failed: /bin/sh -c /home/kacinauskasl/SDK/android-sdk-linux/build-tools/23.0.0-preview/aapt dump badging /home/kacinauskasl/workspace/appiumTests/AppiummProject/apk/myapk.apk
W/zipro ( 7260): Error opening archive /home/kacinauskasl/workspace/appiumTests/AppiummProject/apk/myapk.apk: Invalid file
ERROR: dump failed because assets could not be loaded.
目前我的目标是在AVD或真实设备上启动App。
我非常感谢任何帮助。
答案 0 :(得分:0)
问题解决了。
插入:
capability.setCapability(“appPackage”,“com.my_package_name”); capability.setCapability(“appActivity”,“my_package_name”);
在AVD或真实设备上安装应用程序。