您现在的位置:首页 >> 自然生态

干货 | 读懂 Appium 日志,让测试效能翻倍!

时间:2023-03-03 12:18:00

ug] [BaseDriver] Creating session with MJSONWP desired capabilities: {"app":"/Users/isaac/code/a...

Appium 指令

Appium 是一个 REST 服务于,接收 HTTP 允诺,展览允诺细节,调回某种结果。Appium 客户端副本用线和交叉展览了允诺和调回的细节。在两个交叉两者之间是 Appium 客户端可执行允诺立即的副本讯息:

什么是REST服务于: _state_transfer

[HTTP] ---> GET /wd/hub/status {}

[debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []

[debug] [MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.8.0-beta3","revision":"30e7b45bdc5668124af33c41492aa5195fcdf64d"}}

[HTTP] 缺失清理

利用副本可以更为方便的清理缺失,缺失并不一定愈演愈烈在 automation session 之后。但有时,如果 session 不间断存在,缺失也也许愈演愈烈。所以第一步是推断出缺失在哪。

下面的范例可以看出,每个指令用 [HTTP] ---> 和 [HTTP]

[HTTP] ---> POST /wd/hub/session

[debug] [AndroidDriver] Shutting down Android driver

[debug] [AndroidDriver] Called deleteSession but bootstrap wasn't active

[debug] [Logcat] Stopping logcat capture

[debug] [ADB] Getting connected devices...

[debug] [ADB] 1 device(s) connected

[debug] [ADB] Running '/home/user/Android/Sdk/platform-tools//adb' with args: ["-P",5037,"-s","ec8c4df","shell","am","force-stop","io.appium.unlock"]

[debug] [AndroidDriver] Not cleaning generated files. Add 在在clearSystemFiles在在 capability if wanted.

[MJSONWP] Encountered internal error running command: Error: Cannot stop and clear com.company.app. Original error: Error executing adbExec. Original error: 'Command '/home/user/Android/Sdk/platform-tools//adb -P 5037 -s ec8c4df shell pm clear com.company.app' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: PID 22126 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.company.app'; Code: '1'

at Object.wrappedLogger.errorAndThrow (../../lib/logging.js:63:13)

at ADB.callee$0$0$ (../../../lib/tools/adb-commands.js:334:9)

at tryCatch (/home/linuxbrew/.linuxbrew/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)

at GeneratorFunctionPrototype.invoke [as _invoke] (/home/linuxbrew/.linuxbrew/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)

at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/home/linuxbrew/.linuxbrew/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)

at GeneratorFunctionPrototype.invoke (/home/linuxbrew/.linuxbrew/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)

at

at process._tickCallback (internal/process/next_tick.js:188:7)

[HTTP]

浏览器试图用 Android driver 启动一个 session,但愈演愈烈了缺失。Appium 为打算 session 而关掉并清空 AUT 时发现了缺失,这个缺失让我们告诉大公事:

Appium 正在为了让认真什么 哪里犯错了

在这个范例中,Appium 为了让运转 adb 立即(adb shell am force-stop),adb 常量在缺失讯息中也有标示出。愈演愈烈了 Android 系统实质上缺失。此时,我们可以手动运转这个 adb 立即,看看缺失真的可以重现。如果缺失重现,离线查错吧!如果 adb 立即获得成功运转,也许是 Appium 的 bug,不该去 Github 的 issue 上详细信息或者提交这个 bug 。(范例中的缺失是通讯设备制造商的必要模型造成的)

这个范例只是众多缺失中的一个,但它解释至关极为重要的一点,当缺失愈演愈烈时,副本可以提供更多的讯息,如果不能原始的副本讯息,对 Appium 排错难上加难。

可以扭曲副本输出的常量

并不一定,的系统的副本细节早已足够,如果你想要去 Github 上借此设法,讯息当然越多越好!下面一些常量可以扭曲 Appium 客户端的副本行为:

---log-level - 扭曲Appium副本标示出级别。 Appium 的系统展览所有副本,它有所列一些的系统:'info', 'info:debug', 'info:info', 'info:warn', 'info:error', 'warn', 'warn:debug', 'warn:info', 'warn:warn', 'warn:error', 'error', 'error:debug', 'error:info', 'error:warn', 'error:error', 'debug', 'debug:debug', 'debug:info', 'debug:warn', 'debug:error'。 ---log-no-colors - 如果你的控制台不能粉红色(副本也许会产生一些奇怪的字符,比如"TODO: find the color"),你可以用这个常量重新启动粉红色。 ---log-timestamp - 在副本年前加进小时砍,在清理确保必要缺失都只奇效,展览如下:

2018-03-15 13:17:58:663 - [Appium] Welcome to Appium v1.8.0-beta3 (REV 30e7b45bdc5668124af33c41492aa5195fcdf64d)

2018-03-15 13:17:58:664 - [Appium] Non-default server args:

2018-03-15 13:17:58:665 - [Appium] logTimestamp: true

2018-03-15 13:17:58:732 - [Appium] Appium REST http interface listener started on 0.0.0.0:4723

⬇️ 副本“下方绑定”,增加试验核心经济效益!

>>更多电子技术文章分享和免费档案资料索取

_id=qrcodeMaxfrom=souhuMaxtimestamp=1650785178

南昌男科检查
南京肛肠医院哪家医院好
成都妇科哪家医院最好
治疗颈肩腰腿痛用什么药
广东妇科检查多少钱