Appium 服务器在 运行 测试时检测平台版本错误
Appium server having an error detecting platform version when running tests
我正在尝试 运行 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
主要错误似乎是无法找到 phone 的平台版本。当我 运行 他们正在尝试的代码 adb shell getprop ro.build.version.release
我得到正确的输出 (8.1.0)。我希望得到任何帮助,引导我朝着正确的方向前进。
显示未处理的承诺拒绝。此错误源于在没有 catch 块的情况下在异步函数内部抛出,或者拒绝未使用 .catch() 处理的承诺。 尝试以下代码:
const wdio = require("webdriverio");
const opts = {
port: 4723,
capabilities: {
platformName: "Android",
deviceName: "my Device",
app: "C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
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!");
});
此问题已通过降级 adb 版本解决。以上尝试使用 adb 版本 1.0.39,然后是 1.0.40。我从 xda developers 下载了 adb 1.0.36 并将文件复制并粘贴到我的平台工具文件夹并替换了重复项。 运行 后再次测试。它已成功完成,没有任何问题。 appium 似乎与新的 adb 不兼容。可能是较新的 adb 版本中的新命令集,因为一些旧命令已被弃用。
我正在尝试 运行 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
主要错误似乎是无法找到 phone 的平台版本。当我 运行 他们正在尝试的代码 adb shell getprop ro.build.version.release
我得到正确的输出 (8.1.0)。我希望得到任何帮助,引导我朝着正确的方向前进。
显示未处理的承诺拒绝。此错误源于在没有 catch 块的情况下在异步函数内部抛出,或者拒绝未使用 .catch() 处理的承诺。 尝试以下代码:
const wdio = require("webdriverio");
const opts = {
port: 4723,
capabilities: {
platformName: "Android",
deviceName: "my Device",
app: "C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
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!");
});
此问题已通过降级 adb 版本解决。以上尝试使用 adb 版本 1.0.39,然后是 1.0.40。我从 xda developers 下载了 adb 1.0.36 并将文件复制并粘贴到我的平台工具文件夹并替换了重复项。 运行 后再次测试。它已成功完成,没有任何问题。 appium 似乎与新的 adb 不兼容。可能是较新的 adb 版本中的新命令集,因为一些旧命令已被弃用。