appium Activity used to start app doesn't exist or cannot be launched 问题解决
运行appium测试报错 “error: Failed to start an Appium session, err was: Error: Activity used to start app doesn’t exist or cannot ve launched! Make usre it exists and is launchable activity”
网上很多说法是:“要打开的activity不存在,activity路径错误,改为完整正确的activity路径”
仔细检查了好几遍发现,activity是存在的,activity路径也是正确的(当然这么低端的问题一般人也不会犯)
经过一番查找,问题解决如下:
注释掉setup中的如下两行:
capabilities.setCapability("appPackage", "xxx.xxx.xxx.activity");
capabilities.setCapability("appActivity", ".MainActivity");
再次运行,问题解决了。
说明:说明运行测试的时候我们不需要指定package和activity 这些信息,Appium会从apk中提取这些信息。
见:https://github.com/appium/appium/issues/2981 中paymand 的解释:
Don't know about the apk info tool above, but you can always get that info using the aapt tool from Android SDK with the following command:
adt/sdk/build-tools/android-4.4/aapt dump badging app.apkNote: You shouldn't need to specify appPackage, appActivity, etc. since Appium should be able to extract those from the apk using the method above anyway.

本文解决了一个常见的Appium测试框架问题:“Activity用于启动应用程序不存在或无法启动”。通过注释掉指定appPackage和appActivity的代码,Appium能自动从APK文件中提取这些信息。
4700

被折叠的 条评论
为什么被折叠?



