android - Appium 服务器在运行测试时检测平台版本时出错
问题描述
我正在尝试在 appium 提供的测试应用程序上运行基本测试脚本。我正在使用带有 android 版本 8.1.0 的物理设备 (Nexus 6p)。这是我试图运行的代码(Node.js):
const wdio = require("webdriverio");
const opts = {
port: 4723,
capabilities: {
platformName: "Android",
platformVersion: "8.1.0",
deviceName: "Nexus 6P",
app: "C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
start = async function () {
const elementId = await client.findElement("accessibility id", "TextField1"); client.elementSendKeys(elementId.ELEMENT, "Hello World!");
const elementValue = await client.findElement("accessibility id", "TextField1");
await client.getElementAttribute(elementValue.ELEMENT, "value").then((attr) => {
assert.equal(attr, "Hello World!");
});
}
运行代码并并排观察客户端和服务器后,会发生错误,这就是客户端部分中显示的内容:
ERROR webdriver: Request failed due to unknown error: An unknown server-side error occurred while processing the command. Original error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
at getErrorFromResponseBody (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\utils.js:343:10)
at Request._callback (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\request.js:121:64)
at Request.self.callback (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:185:22)
at Request.emit (events.js:189:13)
at Request.EventEmitter.emit (domain.js:441:20)
at Request.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1161:10)
at Request.emit (events.js:189:13)
at Request.EventEmitter.emit (domain.js:441:20)
at IncomingMessage.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:277:13)
(node:8844) UnhandledPromiseRejectionWarning: unknown error: An unknown server-side error occurred while processing the command. Original error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
at getErrorFromResponseBody (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\utils.js:343:10)
at Request._callback (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\request.js:121:64)
at Request.self.callback (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:185:22)
at Request.emit (events.js:189:13)
at Request.EventEmitter.emit (domain.js:441:20)
at Request.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1161:10)
at Request.emit (events.js:189:13)
at Request.EventEmitter.emit (domain.js:441:20)
at IncomingMessage.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:277:13)
(node:8844) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8844) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
这就是我在 appium 服务器日志上得到的信息:
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1552053337834 (08:55:37 GMT-0500 (Colombia Standard Time))
[BaseDriver] The capabilities ["platformVersion","deviceName","app","automationName"] are not standard capabilities and should have an extension prefix
[Appium] Creating new AndroidUiautomator2Driver (v1.29.1) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] platformVersion: 8.1.0
[Appium] deviceName: Nexus 6P
[Appium] app: C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk
[Appium] automationName: UiAutomator2
[debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: c771d923-3d27-4a63-887f-def40f07b38f
[BaseDriver] Using local app 'C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk'
[debug] [UiAutomator2] Checking whether app is actually present
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '8.1.0'
[debug] [ADB] Setting device id to 84B7N16602000138
[ADB] Getting device platform version
[debug] [ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release'
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1552053338655 (08:55:38 GMT-0500 (Colombia Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
[debug] [W3C] at ADB.methods.getPlatformVersion (C:\Users\JH044350\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:108:11)
[HTTP] <-- POST /wd/hub/session 500 830 ms - 1201
主要错误似乎是无法找到手机的平台版本。当我运行他们正在尝试的代码时,adb shell getprop ro.build.version.release
我得到了正确的输出(8.1.0)。我希望能得到任何帮助来引导我朝着正确的方向前进。
解决方案
此问题已通过降级 adb 版本解决。以上尝试使用 adb 版本 1.0.39 和 1.0.40。我从xda 开发人员那里下载了 adb 1.0.36并将文件复制并粘贴到我的平台工具文件夹并替换了重复项。再次运行测试后。它成功完成,没有问题。appium 似乎与新的 adb 不兼容。也许这是较新的 adb 版本中的新命令集,因为一些较旧的命令已被弃用。
推荐阅读
- c# - 来自 API 的响应 Json 未绑定到我的模型
- vue.js - Vue 3 模板引用动态名称
- airflow - Airflow 的 BeamRunPythonPipelineOperator 无法安装 py_requirements
- python - random_transform() 缺少 1 个必需的位置参数:'x'
- rust - 在 cdylib Rust crate 中使用 ld 版本脚本
- android - 清单合并失败:针对 android 12 及更高版本的应用等
- python - ModuleNotFoundError:没有名为“mplfinance”的模块 | 即使在 pipstall mplfinance 之后也会出错
- igraph - 大图上的社区检测
- ldap - 使用 LDAP 连接时,在气流上的列表用户中不显示编辑记录
- javascript - 如何在空手道中重新开始测试的 If 语句