问题描述
我在 Windows 机器上使用 Appium 实现 Android 原生应用自动化.我的所有场景都运行良好,但有时应用程序崩溃并且 Appium 停止说60 秒内没有收到新命令,正在关闭".
I am using Appium for Android native app automation on windows machine. All my scenarios are doing good, but sometimes the App gets crashed and Appium stops saying "Didn't get a new command in 60 secs, shutting down".
注意 - 如果我明确按下键盘上的任意键,它将在执行黄瓜时获得下一个命令来执行.
Note - if explicitly i press any key from keyboard it will get next command to execute while cucumber execution.
我可以看到 Appium 正在发送查找元素的请求,但没有收到任何响应.我不知道为什么会发生这种情况,但同样的事情大多数情况下没有任何问题.当这个问题发生时,Appium 会关闭应用,接下来的场景也会失败.
I can see Appium is sending request to find the element, but no response has been received. I don't know why this is happening, but the same thing passes without any issue mostly. When this issue happens, Appium closes the app and the next coming scenarios also gets failed.
有人帮助解决这个问题.
Someone help to resolve this issue.
这是 Appium 服务器日志:
This is the Appium server log:
信息:启动应用程序
信息:[调试] 试图杀死所有uiautomator"进程
信息:[调试] 使用uiautomator"获取所有进程
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "ps 'uiautomator'"
信息:[调试] 没有找到匹配的进程
信息:[调试] 运行引导程序
信息:[调试] 生成:C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.paragyte.publicpartnerships.test -e disableAndroidWatchers false
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:numtests=1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:流=
信息:[调试] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:id=UiAutomatorTestRunner
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:test=testRunServer
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:class=io.appium.android.bootstrap.Bootstrap信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:当前=1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE:1
信息:[debug] [BOOTSTRAP] [debug] 套接字在端口 4724 上打开
信息:[debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
信息:[调试] 如果设备不活动则唤醒设备
信息:[调试] 将命令推送到 appium 工作队列:["wake",{}]
信息:[调试] [引导程序] [调试] 正在加载 json...
信息:[debug] [BOOTSTRAP] [debug] json 加载完成.
信息:[debug] [BOOTSTRAP] [debug] 注册崩溃观察者.
信息:[debug] [BOOTSTRAP] [debug] 客户端已连接
info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"wake","params":{}}
信息:[debug] [BOOTSTRAP] [debug] 得到类型为 ACTION
的命令信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:wake
信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0}
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "dumpsys window"
信息:[调试] 屏幕已解锁,继续.
信息:[调试] 将命令推送到 appium 工作队列:["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] 从客户端获取数据:{"cmd":"action","action":"getDataDir","params":{}}
信息:[debug] [BOOTSTRAP] [debug] 得到类型为 ACTION
的命令信息:[debug] [BOOTSTRAP] [debug] 得到命令动作:getDataDir
info: [debug] [BOOTSTRAP] [debug] 返回结果:{"value":"/data/local/tmp","status":0}
信息:[调试] dataDir 设置为:/data/local/tmp
info: [debug] 将命令推送到 appium 工作队列:["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] 从客户端得到数据:{"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
信息:[debug] [BOOTSTRAP] [debug] 得到类型为 ACTION
的命令信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:compressedLayoutHierarchy
信息:[debug] [BOOTSTRAP] [debug] 返回结果:{"value":false,"status":0}
信息:[调试] 获取设备 API 级别
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "getprop ro.build.version.sdk"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"/data/local/tmp","status":0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "getprop ro.build.version.sdk"
信息:[调试] 设备处于 API 级别 19
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "am start -S -a android.intent.action.MAIN -candroid.intent.category.LAUNCHER -f 0x10200000 -n com.paragyte.publicpartnerships.test/com.paragyte.publicpartnerships.SplashActivity"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.paragyte.publicpartnerships.test/com.paragyte.publicpartnerships.SplashActivity"
信息:[调试] 等待 pkg "com.paragyte.publicpartnerships.test" 和活动 "com.paragyte.publicpartnerships.SplashActivity" 成为焦点
信息:[调试]获得重点包和活动
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "dumpsys window windows"
info: [debug] Waiting for pkg "com.paragyte.publicpartnerships.test" and activity "com.paragyte.publicpartnerships.SplashActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "dumpsys window windows"
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "getprop ro.build.version.release"
info: [debug] executing cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "getprop ro.build.version.release"
信息:[调试] 设备版本为 4.4.2
信息:[调试] 设备启动!准备好命令
信息:[调试] 将命令超时设置为默认值 60 秒
信息:[调试] Appium 会话开始于 sessionId 00bd22a6-7f2e-435b-a6af-53f5bf115a2c
信息:<-- POST/wd/hub/session 303 16023.269 ms - 74
信息:--> GET/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c {}
info: [debug] Device is at release version 4.4.2
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 00bd22a6-7f2e-435b-a6af-53f5bf115a2c
info: <-- POST /wd/hub/session 303 16023.269 ms - 74
info: --> GET /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c {}
info: [debug] 成功响应客户端:{"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appiumVersion":"1.6.0","platformName":"Android","platformVersion":"4.4.2","browserName":"","deviceName":"Samsung Galaxy S4 Emulator","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"appiumVersion":"1.6.0","platformName":"Android","deviceName":"300450adeedc3100","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2"}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appiumVersion":"1.6.0","platformName":"Android","platformVersion":"4.4.2","browserName":"","deviceName":"Samsung Galaxy S4 Emulator","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"appiumVersion":"1.6.0","platformName":"Android","deviceName":"300450adeedc3100","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:<-- GET/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c 200 2.411 ms - 691 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appiumVersion":"1.6.0","platformName":"Android","platformVersion":"4.4.2","browserName":"","deviceName":"Samsung Galaxy S4 Emulator","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"appiumVersion":"1.6.0","platformName":"Android","deviceName":"300450adeedc3100","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: <-- GET /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c 200 2.411 ms - 691 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appiumVersion":"1.6.0","platformName":"Android","platformVersion":"4.4.2","browserName":"","deviceName":"Samsung Galaxy S4 Emulator","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"appiumVersion":"1.6.0","platformName":"Android","deviceName":"300450adeedc3100","app":"D:\Automation\Mobile\apk_files/app-debug.apk","name":"Time 4 Care"},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:--> GET/wd/hub/status {}
info: --> GET /wd/hub/status {}
info: [debug] 成功响应客户端:{"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:<-- GET/wd/hub/status 200 5.141 ms - 156 {"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: <-- GET /wd/hub/status 200 5.141 ms - 156 {"status":0,"value":{"build":{"version":"1.4.13","revision":"c75d8adcb66a75818a542fe1891a34260c21f76a"}},"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:--> POST/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/timeouts/implicit_wait {"ms":0}
info: [debug] 将 Android 隐式等待设置为 0ms
info: --> POST /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/timeouts/implicit_wait {"ms":0}
info: [debug] Set Android implicit wait to 0ms
信息:[调试] 成功响应客户端:{"status":0,"value":null,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:<-- POST/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/timeouts/implicit_wait 200 2.471 ms - 76 {"status":0,"session":null,"":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: <-- POST /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/timeouts/implicit_wait 200 2.471 ms - 76 {"status":0,"value":null,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:--> POST/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/appium/device/press_keycode {"keycode":93}
info: [debug] 将命令推送到 appium 工作队列:["pressKeyCode",{"keycode":93,"metastate":null}]
info: --> POST /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/appium/device/press_keycode {"keycode":93}
info: [debug] Pushing command to appium work queue: ["pressKeyCode",{"keycode":93,"metastate":null}]
info: [debug] [BOOTSTRAP] [debug] 从客户端得到数据:{"cmd":"action","action":"pressKeyCode","params":{"keycode":93,"metastate":null}}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"pressKeyCode","params":{"keycode":93,"metastate":null}}
info: [debug] [BOOTSTRAP] [debug] 得到了 ACTION 类型的命令
信息:[debug] [BOOTSTRAP] [debug] 得到命令操作:pressKeyCode
info: [debug] [BOOTSTRAP] [debug] 返回结果:{"value":true,"status":0}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: pressKeyCode
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] 成功响应客户端: {"status":0,"value":true,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:<-- POST/wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/appium/device/press_keycode 200 258.139 ms - 76 {"status":0,"value":true,"sessionId:"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
info: <-- POST /wd/hub/session/00bd22a6-7f2e-435b-a6af-53f5bf115a2c/appium/device/press_keycode 200 258.139 ms - 76 {"status":0,"value":true,"sessionId":"00bd22a6-7f2e-435b-a6af-53f5bf115a2c"}
信息:[调试] 60 秒内没有收到新命令,正在关闭...
信息:关闭 appium 会话
信息:[调试]按HOME键
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] 执行 cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "input keyevent 3"
info: [debug] executing cmd: C:\Users\PG106\AppData\Local\Android\sdk\platform-tools\adb.exe -s 300450adeedc3100 shell "input keyevent 3"
信息:[调试] 停止 logcat 捕获
信息:[调试] Logcat 终止,代码为空,信号 SIGTERM
信息:[debug] [BOOTSTRAP] [debug] 从客户端得到数据:{"cmd":"shutdown"}
信息:[debug] [BOOTSTRAP] [debug] 得到 SHUTDOWN
类型的命令info: [debug] [BOOTSTRAP] [debug] 返回结果:{"value":"OK,正在关闭","status":0}
信息:[debug] [BOOTSTRAP] [debug] 关闭客户端连接
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:numtests=1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:stream=.
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:id=UiAutomatorTestRunner
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:test=testRunServer
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:class=io.appium.android.bootstrap.Bootstrap
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:当前=1
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE:0
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS:流=
信息:[调试] [UIAUTOMATOR STDOUT] WatcherResultPrinter=.
的测试结果信息:[调试] [UIAUTOMATOR STDOUT] 时间:63.073
信息:[调试] [UIAUTOMATOR STDOUT] OK(1 次测试)
信息:[调试] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE:-1
info: [debug] 发送关闭命令,等待 UiAutomator 停止...
信息:[调试] UiAutomator 正常关闭
信息:[调试] 清理 android 对象
信息:[调试] 清理 appium 会话
info: [debug] 我们关闭了,因为没有新命令进来
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 63.073
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in
谢谢,卡皮尔
推荐答案
您是否尝试将所需的功能设置为更高的数字?当前设置为什么?
Have you tried setting your desired capability to a higher number? What is it currently set to?
desiredCapabilities.setCapability("newCommandTimeout", 10000);
这篇关于Appium 服务器关闭,因为没有新命令进来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!