有人可以帮我解决这个问题,我不熟悉Appium进行的Android测试,我正尝试在AVD中打开应用,但该应用已安装,但随后出现错误“无法创建新会话。(原始错误:命令失败: )“,” killed“:false,” code“:1,” signal“:null,” origValue“:”命令失败:“},” sessionId“:null}
非常感谢您的帮助
尝试仅提供功能。setCapability(“ appActivity”,“ .MainActivity”);
'''
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/src/");
File app = new File(appDir, "ChatApp-release.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.aaa.charla");
capabilities.setCapability("appActivity", "com.aaa.xxx.MainActivity");
driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
以下是调试日志:
信息:控制台日志级别:调试 信息:-> POST / wd / hub / session {“ desiredCapabilities”:{“ app”:“ D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk” ,“ appPackage”:“ com.odysseyinc.charla”,“ appActivity”:“ com.odyssey.chatapp.MainActivity”,“ newCommandTimeout”:“ 10000”,“ platformName”:“ Android”,“ version”:“ 7.1。 1“,” deviceName“:” emulator-5554“}} 信息:客户端用户代理字符串:Apache-HttpClient / 4.5.2(Java / 1.8.0_162) 信息:[调试]提供了以下所需功能,但appium无法识别。它们将被传递到此服务器上运行的任何其他服务。 :版本 信息:[调试]使用所需上限的本地应用程序:D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk 信息:[调试]创建新的appium会话0d25aeac-d055-449f-af84-b6d314d9b4a5 信息:启动android appium 信息:[调试]获取Java版本 信息:Java版本是:1.8.0_162 信息:[调试]检查adb是否存在 信息:[调试]使用来自C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe的adb 信息:[调试]将chromedriver二进制文件设置为:C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ chromedriver \ windows \ chromedriver.exe 信息:[调试]使用快速重置?真正 信息:[调试]准备会话的设备 信息:[调试]检查应用是否确实存在 信息:检索设备 信息:[调试]试图找到连接的android设备 信息:[调试]正在连接设备... 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe设备 信息:[调试]已连接1台设备 信息:找到设备模拟器-5554 信息:[调试]将设备ID设置为模拟器-5554 信息:[调试]等待设备准备就绪并响应外壳命令(超时= 5) 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554等待设备 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ echo'ready'” 信息:[调试]开始捕获logcat 信息:[调试]获取设备API级别 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ getprop ro.build.version.sdk” 信息:[调试]设备处于API级别25 信息:设备API级别是:25 信息:[调试]提取语言字符串:默认 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ getproppersist.sys.language” 信息:[调试]当前设备persist.sys.language: 信息:[调试] java -jar“ C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ appium_apk_tools.jar”“ stringsFromApk”“ D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk“”“ C:\ Users \ UNMESH〜1.GHA \ AppData \ Local \ Temp \ com.odysseyinc.charla” 信息:[调试]从转换后的strings.json中读取字符串 信息:[调试]将语言设置为默认 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 push“ C:\ Users \ UNMESH〜1.GHA \ AppData \ Local \ Temp \ com.odysseyinc.charla \ strings.json“ / data / local / tmp 信息:[调试]检查是否存在aapt 信息:[调试]从C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ build-tools \ 28.0.3 \ aapt.exe使用aapt 信息:[调试]从清单中检索过程。 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ build-tools \ 28.0.3 \ aapt.exe dump xmltree D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk AndroidManifest.xml 信息:[调试]将应用程序进程设置为:com.odysseyinc.charla 信息:[调试]由于服务器未以--full-reset启动,因此未卸载应用程序 信息:[调试]检查应用程序证书是否为D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk。 信息:[调试]执行cmd:java -jar“ C:\ Program Files(x86)\ Appium \ node_modules \ appium \ node_modules \ appium-adb \ jars \ verify.jar” D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk 信息:[调试]应用程序已签名。 信息:[调试]压缩对齐D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk 信息:[调试]检查zipalign是否存在 信息:[调试]从C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ build-tools \ 28.0.3 \ zipalign.exe使用zipalign 信息:[调试]压缩对齐的apk。 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ build-tools \ 28.0.3 \ zipalign.exe -f 4 D:\ AndroidNew \ Yrreport \ YrReport \ RemoteSystemsTempFiles \ Appium \ apk \ ChatApp-master-0.9.35.1195-release.apk C:\ Users \ UNMESH〜1.GHA \ AppData \ Local \ Temp \ 119427-15556-1rmbgw9 \ appium.tmp 信息:[调试]应用程序的MD5为f3d7efc8b197792c3d0529a48dc92ff2 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ ls /data/local/tmp/f3d7efc8b197792c3d0529a48dc92ff2.apk ” 信息:[调试]获取com.odysseyinc.charla的安装状态 信息:[调试]获取设备API级别 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ getprop ro.build.version.sdk” 信息:[调试]设备处于API级别25 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ pm list package -3 com.odysseyinc.charla” 信息:[调试]应用已安装 信息:应用程序已安装,正在重置应用程序 信息:[调试]运行快速重置(停止并清除) 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ am force-stop com.odysseyinc.charla” 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 shell“ pm clear com.odysseyinc.charla” 信息:[调试]转发系统:4724到设备:4724 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554转发tcp:4724 tcp:4724 信息:[调试]将appium引导程序推入设备... 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554 push“ C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ android_bootstrap \ AppiumBootstrap.jar“ / data / local / tmp / 信息:[调试]将设置apk推送到设备... 信息:[调试]执行cmd:C:\ Users \ unmesh.ghatbandhe \ AppData \ Local \ Android \ Sdk \ platform-tools \ adb.exe -s emulator-5554安装“ C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk“ 信息:[调试]停止logcat捕获 信息:[调试] Logcat终止,代码为空,信号SIGTERM 信息:[调试]发送关闭命令,等待UiAutomator停止... 警告:UiAutomator没有足够快地关闭,称其消失了 错误:无法启动Appium会话,错误是:错误:命令失败:adb:无法安装C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS :尝试在不首先卸载的情况下重新安装io.appium.settings。]
信息:[调试]清理android对象 信息:[调试]清理appium会话 信息:[debug]错误:命令失败:adb:无法安装C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS:尝试重新安装io .appium.settings,而无需先卸载。]
at ChildProcess.exithandler (child_process.js:637:15) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Process.ChildProcess._handle.onexit (child_process.js:810:5)
信息:[调试]响应客户端,错误:{“状态”:33,“值”:{“消息”:“无法创建新的会话。(原始错误:命令失败:adb:失败安装C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS:尝试重新安装io.appium.settings而不先卸载。] \ r \ n) “,” killed“:false,”代码“:1,” signal“:null,” origValue“:”命令失败:adb:安装C:\ Program Files(x86)\ Appium \ node_modules \ appium \ build \ settings_apk \ settings_apk-debug.apk:失败[INSTALL_FAILED_ALREADY_EXISTS:尝试不首先卸载就重新安装io.appium.settings。] \ r \ n“},” sessionId“:null} 信息:<-POST / wd / hub / session 500 32039.992 ms-664
`
答案 0 :(得分:0)
您需要共享完整的appium日志,以了解原因。 [检查日志后] 对于特定的Android映像,这是一个已知问题,因为它会安装2个版本的appium设置应用和解锁应用。您可以做的是在启动脚本之前更改要测试的android映像或卸载这两个应用程序。
您可以通过启动模拟器GUI手动卸载它们,并使用鼠标或通过以下命令进行卸载:
adb -s device_serial uninstall io.appium.settings
adb -s device_serial uninstall io.appium.unlock
此外,如果您确实必须在android 7设备上执行以下测试,则可以在代码中添加这些命令:
String androidVersion=executeCommand("adb shell getprop ro.build.version.release");
if(androidVersion.contains("7"))
{
//uninstall appium settings app
cmd="adb uninstall io.appium.settings";
executeCommand(cmd);
//uninstall appium unlock app
cmd="adb uninstall io.appium.unlock";
executeCommand(cmd);
}
答案 1 :(得分:0)
我已将Appuim 1.4升级到1.9,并开始按预期工作。