Appium 直接用 appium 可以连接真机,用 pycharm 运行脚本时报错 “'platformVersion' must be of type string”

王子昊 · 2020年05月31日 · 最后由 王子昊 回复于 2020年06月02日 · 2998 次阅读

selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): 'platformVersion' must be of type string

appium log

[Appium] Welcome to Appium v1.17.0
[Appium] Non-default server args:
[Appium]   allowInsecure: {
[Appium]   }
[Appium]   denyInsecure: {
[Appium]   }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"IOS","appium:platformVersion":12.2,"appium:deviceName":"IPhone","appium:automationName":"XCUITest","appium:bundleId":"net.powerinfo.face2face","appium:udid":"aa94d167fa1165e50027056d1f4697b728d8b583","appium:newCommandTimeout":3600,"appium:autoAcceptAlerts":true,"appium:noReset":true,"appium:useNewWDA":true}]},"desiredCapabilities":{"platformName":"IOS","platformVersion":12.2,"deviceName":"IPhone","automationName":"XCUITest","bundleId":"net.powerinfo.face2face","udid":"aa94d167fa1165e50027056d1f4697b728d8b583","newCommandTimeout":3600,"autoAcceptAlerts":true,"noReset":true,"useNewWDA":true}}
[W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"IOS","platformVersion":12.2,"deviceName":"IPhone","automationName":"XCUITest","bundleId":"net.powerinfo.face2face","udid":"aa94d167fa1165e50027056d1f4697b728d8b583","newCommandTimeout":3600,"autoAcceptAlerts":true,"noReset":true,"useNewWDA":true},null,{"firstMatch":[{"platformName":"IOS","appium:platformVersion":12.2,"appium:deviceName":"IPhone","appium:automationName":"XCUITest","appium:bundleId":"net.powerinfo.face2face","appium:udid":"aa94d167fa1165e50027056d1f4697b728d8b583","appium:newCommandTimeout":3600,"appium:autoAcceptAlerts":true,"appium:noReset":true,"appium:useNewWDA":true}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1590903729578 (13:42:09 GMT+0800 (中国标准时间))
[Appium] Could not parse W3C capabilities: 'platformVersion' must be of type string
[Appium] Trying to fix W3C capabilities by merging them with JSONWP caps
[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:
[BaseDriver]   platformVersion
[BaseDriver]   deviceName
[BaseDriver]   automationName
[BaseDriver]   bundleId
[BaseDriver]   udid
[BaseDriver]   newCommandTimeout
[BaseDriver]   autoAcceptAlerts
[BaseDriver]   noReset
[BaseDriver]   useNewWDA
[Appium] Could not parse fixed W3C capabilities: 'platformVersion' must be of type string. Falling back to JSONWP protocol
[Appium] Appium v1.17.0 creating new XCUITestDriver (v3.17.0) session
[BaseDriver] Creating session with MJSONWP desired capabilities: {
[BaseDriver]   "platformName": "IOS",
[BaseDriver]   "platformVersion": 12.2,
[BaseDriver]   "deviceName": "IPhone",
[BaseDriver]   "automationName": "XCUITest",
[BaseDriver]   "bundleId": "net.powerinfo.face2face",
[BaseDriver]   "udid": "aa94d167fa1165e50027056d1f4697b728d8b583",
[BaseDriver]   "newCommandTimeout": 3600,
[BaseDriver]   "autoAcceptAlerts": true,
[BaseDriver]   "noReset": true,
[BaseDriver]   "useNewWDA": true
[BaseDriver] }
[BaseDriver] SessionNotCreatedError: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): 'platformVersion' must be of type string
[BaseDriver]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:226:25)
[BaseDriver]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:1001:16)
[BaseDriver]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/session.js:46:8)
[BaseDriver]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:211:43)
[BaseDriver]     at AppiumDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:358:43)
[BaseDriver]     at processTicksAndRejections (internal/process/task_queues.js:85:5)
[XCUITest] SessionNotCreatedError: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): 'platformVersion' must be of type string
[XCUITest]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:226:25)
[XCUITest]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:1001:16)
[XCUITest]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/session.js:46:8)
[XCUITest]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:211:43)
[XCUITest]     at AppiumDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:358:43)
[XCUITest]     at processTicksAndRejections (internal/process/task_queues.js:85:5)
[DevCon Factory] Neither device UDID nor local port is set. Did not know how to release the connection
[BaseDriver] Event 'newSessionStarted' logged at 1590903730467 (13:42:10 GMT+0800 (中国标准时间))
[MJSONWP] Encountered internal error running command: SessionNotCreatedError: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): 'platformVersion' must be of type string
[MJSONWP]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:226:25)
[MJSONWP]     at XCUITestDriver.validateDesiredCaps (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:1001:16)
[MJSONWP]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/session.js:46:8)
[MJSONWP]     at XCUITestDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:211:43)
[MJSONWP]     at AppiumDriver.createSession (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/lib/appium.js:358:43)
[MJSONWP]     at processTicksAndRejections (internal/process/task_queues.js:85:5)
[MJSONWP] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 895 ms - 212
共收到 3 条回复 时间 点赞

log 都告诉你了,platformVersion 要传字符串啊

一楼正解,加上双引号试试吧

巫师师 回复

可以了,谢谢两位大佬

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