Appium 连接 iOS 真机报错:Could not load a driver for platformName 'ios'.

季文洪 · 2023年03月22日 · 最后由 季文洪 回复于 2023年11月28日 · 8330 次阅读

Xcode 14.3beta3
iPhone 16.3.1
Appium Server GUI 1.22.3-4
Appium Inspector

Xcde 里面城市连接真机是没有问题的。
使用 Appium Inspector 连接的时候失败:
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Could not load a driver for platformName 'iOS'. Please verify your Appium installation

platformName:iOS 不认识了?现在应该填啥了

共收到 12 条回复 时间 点赞

Please verify your Appium installation ,说明 Appium 环境配置有问题,应该是少了某些部件,如果没猜错的话,Android 也可能会报 Could not load a driver for platformName 'Android'

Time 回复

android 没有问题的。

appium-doctor 诊断看起来也不去缺啥。

sh-3.2# appium-doctor --ios
WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global"
info AppiumDoctor Appium Doctor v.1.16.2
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ✔ Node version is 18.15.0
info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode14.3beta3.app/Contents/Developer
info AppiumDoctor ✔ Xcode Command Line Tools are installed in: /Applications/Xcode14.3beta3.app/Contents/Developer
info AppiumDoctor ✔ DevToolsSecurity is enabled.
info AppiumDoctor ✔ The Authorization DB is set up properly.
info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.35.0
info AppiumDoctor ✔ HOME is set to: /var/root
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor ✖ opencv4nodejs cannot be found.
WARN AppiumDoctor ✖ ffmpeg cannot be found
WARN AppiumDoctor ✖ mjpeg-consumer cannot be found.
WARN AppiumDoctor ✖ set-simulator-location is not installed
WARN AppiumDoctor ✖ idb and idb_companion are not installed
WARN AppiumDoctor ✖ applesimutils cannot be found
info AppiumDoctor ✔ ios-deploy is installed at: /usr/local/bin/ios-deploy. Installed version is: 1.12.1
info AppiumDoctor ### Diagnostic for optional dependencies completed, 6 fixes possible. ###
info AppiumDoctor
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor ➜ Why opencv4nodejs is needed and how to install it: http://appium.io/docs/en/writing-running-appium/image-comparison/
WARN AppiumDoctor ➜ ffmpeg is needed to record screen features. Please read https://www.ffmpeg.org/ to install it
WARN AppiumDoctor ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.
WARN AppiumDoctor ➜ set-simulator-location is needed to set location for Simulator. Please read https://github.com/lyft/set-simulator-location to install it
WARN AppiumDoctor ➜ Why idb is needed and how to install it: https://github.com/appium/appium-idb
WARN AppiumDoctor ➜ Why applesimutils is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/
info AppiumDoctor
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!

七街老酒 回复

/Applications/Xcode14.3beta3.app/Contents/Developer/usr/bin/xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=00008030-001505490213802E' test
用这个命令试了下,开始是报错 ‘WebDriverAgent.xcodeproj’ 找不到,拷贝了一份 appium-webdriveragent 到/usr/local/lib/node_modules/appium/node_modules/下面,
在 Xcode Test 了一下可以往 iOS 安装 WebDriverAgent;继续执行命令,当前的报错:
Testing failed:
No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "YY68N7Z46L" with a private key was found.
No profiles for 'com.xdpi.webdrive.xctrunner' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.xdpi.webdrive.xctrunner'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.
Testing cancelled because the build failed.

** TEST FAILED **

我把目前详细的日志放上来,这是在 appium server gui 里面的:

The server is running
[Appium] Welcome to Appium v1.22.2
[Appium] Non-default server args:
[Appium] relaxedSecurityEnabled: true
[Appium] allowInsecure: {
[Appium] }
[Appium] denyInsecure: {
[Appium] }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> GET /wd/hub/sessions
[HTTP] {}
[GENERIC] Calling AppiumDriver.getSessions() with args: []
[GENERIC] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 304 4 ms - -
[HTTP]
[HTTP] --> GET /wd/hub/sessions
[HTTP] {}
[GENERIC] Calling AppiumDriver.getSessions() with args: []
[GENERIC] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 304 1 ms - -
[HTTP]
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"alwaysMatch":{"appium:udid":"00008030-001505490213802E","platformName":"iOS","appium:deviceName":"iphonex","appium:bundleId":"com.tencent.live4iphone","appium:platformVersion":"16.3.1","appium:xcodeOrgId":"YY68N7Z46L","appium:xcodeSigningId":"iPhone Developer","appium:noReset":true,"appium:includeSafariInWebviews":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]},"desiredCapabilities":{"appium:udid":"00008030-001505490213802E","platformName":"iOS","appium:deviceName":"iphonex","appium:bundleId":"com.tencent.live4iphone","appium:platformVersion":"16.3.1","appium:xcodeOrgId":"YY68N7Z46L","appium:xcodeSigningId":"iPhone Developer","appium:noReset":true,"appium:includeSafariInWebviews":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true}}
[W3C] Calling AppiumDriver.createSession() with args: [{"appium:udid":"00008030-001505490213802E","platformName":"iOS","appium:deviceName":"iphonex","appium:bundleId":"com.tencent.live4iphone","appium:platformVersion":"16.3.1","appium:xcodeOrgId":"YY68N7Z46L","appium:xcodeSigningId":"iPhone Developer","appium:noReset":true,"appium:includeSafariInWebviews":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},null,{"alwaysMatch":{"appium:udid":"00008030-001505490213802E","platformName":"iOS","appium:deviceName":"iphonex","appium:bundleId":"com.tencent.live4iphone","appium:platformVersion":"16.3.1","appium:xcodeOrgId":"YY68N7Z46L","appium:xcodeSigningId":"iPhone Developer","appium:noReset":true,"appium:includeSafariInWebviews":true,"appium:newCommandTimeout":3600,"appium:connectHardwareKeyboard":true},"firstMatch":[{}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1679563764126 (17:29:24 GMT+0800 (中国标准时间))
[Appium] DeprecationWarning: 'automationName' capability was not provided. Future versions of Appium will require 'automationName' capability to be set for iOS sessions.
[Appium] Requested iOS support with version >= 10, using 'XCUITest' driver instead of UIAutomation-based driver, since the latter is unsupported on iOS 10 and up.
[Appium] /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent/index.js:1
[Appium] import * as dependencies from './lib/check-dependencies';
[Appium] ^
[Appium]
[Appium] SyntaxError: Cannot use import statement outside a module
[Appium] at Module._compile (internal/modules/cjs/loader.js:815:22)
[Appium] at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
[Appium] at Module.load (internal/modules/cjs/loader.js:735:32)
[Appium] at Module._load (internal/modules/cjs/loader.js:648:12)
[Appium] at Module._load (electron/js2c/asar.js:717:26)
[Appium] at Function.Module._load (electron/js2c/asar.js:717:26)
[Appium] at Module.require (internal/modules/cjs/loader.js:775:19)
[Appium] at require (internal/modules/cjs/helpers.js:68:18)
[Appium] at Object. (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:5:1)
[Appium] at Module._compile (internal/modules/cjs/loader.js:880:30)
[Appium] at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
[Appium] at Module.load (internal/modules/cjs/loader.js:735:32)
[Appium] at Module._load (internal/modules/cjs/loader.js:648:12)
[Appium] at Module._load (electron/js2c/asar.js:717:26)
[Appium] at Function.Module._load (electron/js2c/asar.js:717:26)
[Appium] at Module.require (internal/modules/cjs/loader.js:775:19)
[Appium] at require (internal/modules/cjs/helpers.js:68:18)
[Appium] at Object. (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/index.js:4:1)
[Appium] at Module._compile (internal/modules/cjs/loader.js:880:30)
[Appium] at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
[Appium] at Module.load (internal/modules/cjs/loader.js:735:32)
[Appium] at Module._load (internal/modules/cjs/loader.js:648:12)
[Appium] at Module._load (electron/js2c/asar.js:717:26)
[Appium] at Function.Module._load (electron/js2c/asar.js:717:26)
[Appium] at Module.require (internal/modules/cjs/loader.js:775:19)
[Appium] at require (internal/modules/cjs/helpers.js:68:18)
[Appium] at AppiumDriver.getDriverAndVersionForCaps (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:252:24)
[Appium] at AppiumDriver.createSession (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:340:66)
[BaseDriver] Event 'newSessionStarted' logged at 1679563764188 (17:29:24 GMT+0800 (中国标准时间))
[W3C] Encountered internal error running command: Error: Could not load a driver for platformName 'iOS'. Please verify your Appium installation
[W3C] at AppiumDriver.getDriverAndVersionForCaps (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:268:11)
[W3C] at AppiumDriver.createSession (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:340:66)
[W3C] at commandExecutor (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:335:9)
[W3C] at AppiumDriver.executeCommand (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:349:15)
[W3C] at AppiumDriver.executeCommand (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/lib/appium.js:549:26)
[W3C] at asyncHandler (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:297:34)
[W3C] at /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:423:15
[W3C] at Layer.handle as handle_request
[W3C] at next (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/route.js:137:13)
[W3C] at Route.dispatch (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/route.js:112:3)
[W3C] at Layer.handle as handle_request
[W3C] at /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:281:22
[W3C] at Function.process_params (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[W3C] at next (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[W3C] at logger (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/morgan/index.js:144:5)
[W3C] at Layer.handle as handle_request
[W3C] at trim_prefix (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:317:13)
[W3C] at /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:284:7
[W3C] at Function.process_params (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[W3C] at next (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[W3C] at /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/body-parser/lib/read.js:130:5
[W3C] at invokeCallback (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:224:16)
[W3C] at done (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:213:7)
[W3C] at IncomingMessage.onEnd (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/raw-body/index.js:273:7)
[W3C] at IncomingMessage.emit (events.js:208:15)
[W3C] at endReadableNT (_stream_readable.js:1168:12)
[W3C] at processTicksAndRejections (internal/process/task_queues.js:77:11)
[HTTP] <-- POST /wd/hub/session 500 88 ms - 757
[HTTP]

[Appium] Requested iOS support with version >= 10, using 'XCUITest' driver instead of UIAutomation-based driver, since the latter is unsupported on iOS 10 and up.
[Appium] /Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent/index.js:1
[Appium] import * as dependencies from './lib/check-dependencies';
[Appium] ^
[Appium]
[Appium] SyntaxError: Cannot use import statement outside a module
[Appium] at Module._compile (internal/modules/cjs/loader.js:815:22)

从日志看,有可能是这个报错导致 ios driver 没有被正确 import ,导致后续的报错。

一般这类问题来自于 node 版本过低不兼容新的语法,可以看看 appium 官方文档提及的 node 版本要求是多少?或者直接下载 appium desktop 来启动(desktop 版本内置了 node 以及各种依赖,基本不会有这类问题)

请假回老家祭祖,好好拜了拜,今天上班理了下思路,准备大搞一下!

卸载已经装好的 appium-desktop,重新下载了一个安装好;
重点来了,没有按之前的思路,先打开 WebDriverAgent.xcodeproj 在 Xcode 里面 Test 通过;
直接打开 Appium Inspector,用之前的手机信息连接 iPhone 手机,直接就连上了。
我。。。
所以是我之前做的太多了?用用再看看有没有其他问题吧

结束!😂 😂 😂

我也遇上了,解决不了,好难受啊!!!

我的报错是:Error
Failed to create session. An unknown server-side error occurred while processing the command. Original error: Could not load a driver for automationName 'XCuiTest' and platformName 'iOS'. Please verify your Appium installation

魔球 回复

最近搞定了吗?你用的啥版本?

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