我正在尝试在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)。我希望能得到任何帮助,以正确的方向指导我。
答案 0 :(得分:-1)
此问题已通过降级ADB版本解决。尝试使用adb版本1.0.39和1.0.40进行上述操作。我从xda developers下载了adb 1.0.36 ,然后将文件复制并粘贴到我的platform-tools文件夹中,然后替换了重复的文件。再次运行测试后。它顺利完成,没有任何问题。似乎appium与新的adb不兼容。可能是较新的adb版本中的新命令集,因为一些较旧的命令已弃用。