问答 appium 用例运行出错没有日志:[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection

匿名 · 2017年06月21日 · 最后由 xyh421 回复于 2017年06月23日 · 2028 次阅读

1、直接运行用例时,可以正常运行,日志如下:
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 24.758
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'

2、但是以这种方式运行 os.popen("python case.py"),用例执行失败,日志如下:
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'

3、后来实验发现有种方式可以让第 2 种方式成功运行:

def ur(a):
    if a == 1:
        os.popen("python case.py")
        pid = os.getpid()
        os.kill(pid=pid, sig=signal.SIGKILL)
    elif a == 2:
        os.popen("adb logcat")
pool = ThreadPool(4)
lists = list([1, 2])
pool.map(ur, lists)
pool.close()
pool.join()

请注意:必须要这种持续运行的 adb 命令才行 os.popen("adb logcat"),如果把"adb logcat"换成"adb devices"或者非 adb 命令都还是会失败。

以上都是一行一行的对比用例执行成功和失败的 appium 的日志发现的区别。

求原因。。。。。。谢谢!

共收到 1 条回复 时间 点赞

appium 设置
试试这个命令 adb logcat -d -c >xxxxxx.log.1
-d dump the log and then exit (don't block)

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册