Appium:Android 和 iOS 的capabilities是否需要前缀?

在较新的 Appium 和 W3C WebDriver 标准中,能力名称需要加上命名空间前缀(如 appium:)。这是因为 W3C 标准化了能力的结构,要求所有自定义能力都必须使用前缀来区分。Appium 使用 appium: 前缀来标记其专用的能力。

iOS 能力:如 appium:udid 和 appium:automationName,需要添加前缀。
Android 能力:同样需要添加前缀,例如 appium:appPackage。

例如,iOS的配置:

iPhoneX:
  platformName: iOS
  appium:udid: f12345678905a81c0fe2d22f12345678907e90ef
  appium:automationName: XCUITest
  appium:platformVersion: "16.5.1"
  appium:newCommandTimeout: 600

Android的配置:

S10e:
  platformName: Android
  appium:automationName: uiautomator2
  appium:deviceName: R58M165SSVL
  appium:platformVersion: "12"
  appium:appPackage: com.1234567.android
  appium:appActivity: com.1234567.android.SplashActivity
  appium:noReset: true
  appium:autoGrantPermissions: true
  appium:newCommandTimeout: 360000

【注意事项】
1、平台名称是否需要前缀?
   platformName 不需要前缀,因为它是 W3C 标准的一部分。
2、加载 YAML 配置时的兼容性 如果使用 yaml.safe_load() 加载配置文件,会直接得到一个字典,格式已经符合 Appium 的预期。
3、通过添加 appium: 前缀后,配置将更加符合 W3C 标准,同时避免在最新 Appium 环境下出现不兼容问题。

[info] [Appium] Welcome to Appium v1.20.2 [info] [Appium] Non-default server args: [info] [Appium] relaxedSecurityEnabled: true [info] [Appium] allowInsecure: { [info] [Appium] } [info] [Appium] denyInsecure: { [info] [Appium] } [info] [Appium] Appium REST http interface listener started on 0.0.0.0:4723[info] [HTTP] --> GET /wd/hub/sessions [info] [HTTP] {} [debug] [GENERIC] Calling AppiumDriver.getSessions() with args: [] [debug] [GENERIC] Responding to client with driver.getSessions() result: [] [info] [HTTP] <-- GET /wd/hub/sessions 200 5 ms - 40 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session [info] [HTTP] {"desiredCapabilities":{"platformName\"":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}} [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName\"":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1750921438941 (15:03:58 GMT+0800 (中国标准时间)) [debug] [BaseDriver] Event 'newSessionStarted' logged at 1750921438942 (15:03:58 GMT+0800 (中国标准时间)) [debug] [MJSONWP] Encountered internal error running command: Error: You must include a platformName capability [debug] [MJSONWP] at AppiumDriver.getDriverAndVersionForCaps (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:216:13) [debug] [MJSONWP] at AppiumDriver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:324:66) [debug] [MJSONWP] at commandExecutor (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:334:9) [debug] [MJSONWP] at AppiumDriver.executeCommand (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:348:15) [debug] [MJSONWP] at AppiumDriver.executeCommand (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:533:26) [debug] [MJSONWP] at asyncHandler (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:297:34) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:423:15 [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:137:13) [debug] [MJSONWP] at Route.dispatch (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\route.js:112:3) [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:281:22 [debug] [MJSONWP] at Function.process_params (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:335:12) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10) [debug] [MJSONWP] at logger (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\morgan\index.js:144:5) [debug] [MJSONWP] at Layer.handle [as handle_request] (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\layer.js:95:5) [debug] [MJSONWP] at trim_prefix (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:317:13) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:284:7 [debug] [MJSONWP] at Function.process_params (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:335:12) [debug] [MJSONWP] at next (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\express\lib\router\index.js:275:10) [debug] [MJSONWP] at D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\body-parser\lib\read.js:130:5 [debug] [MJSONWP] at invokeCallback (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:224:16) [debug] [MJSONWP] at done (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:213:7) [debug] [MJSONWP] at IncomingMessage.onEnd (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\raw-body\index.js:273:7) [debug] [MJSONWP] at IncomingMessage.emit (events.js:208:15) [debug] [MJSONWP] at endReadableNT (_stream_readable.js:1168:12) [debug] [MJSONWP] at processTicksAndRejections (internal/process/task_queues.js:77:11) [info] [HTTP] <-- POST /wd/hub/session 500 27 ms - 179 [info] [HTTP]  [info] [HTTP] --> DELETE /wd/hub/session [info] [HTTP] {} [debug] [HTTP] No route found for /wd/hub/session [info] [HTTP] <-- DELETE /wd/hub/session 404 5 ms - 211 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session [info] [HTTP] {"desiredCapabilities":{"ensureWebviewsHavePages":true,"platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}} [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"ensureWebviewsHavePages":true,"platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null] [debug] [BaseDriver] Event 'newSessionRequested' logged at 1750921458583 (15:04:18 GMT+0800 (中国标准时间)) [warn] [Appium] [warn] [Appium] ====================================================================== [warn] [Appium] DEPRECATION WARNING: [warn] [Appium] [warn] [Appium] The 'automationName' capability was not provided in the desired [warn] [Appium] capabilities for this Android session [warn] [Appium] [warn] [Appium] Setting 'automationName=UiAutomator2' by default and using the [warn] [Appium] UiAutomator2 Driver [warn] [Appium] [warn] [Appium] The next major version of Appium (2.x) will **require** the [warn] [Appium] 'automationName' capability to be set for all sessions on all [warn] [Appium] platforms [warn] [Appium] [warn] [Appium] In previous versions (Appium <= 1.13.x), the default was [warn] [Appium] 'automationName=UiAutomator1' [warn] [Appium] [warn] [Appium] If you wish to use that automation instead of UiAutomator2, please [warn] [Appium] add 'automationName=UiAutomator1' to your desired capabilities [warn] [Appium] [warn] [Appium] For more information about drivers, please visit [warn] [Appium] http://appium.io/docs/en/about-appium/intro/ and explore the [warn] [Appium] 'Drivers' menu [warn] [Appium] [warn] [Appium] ====================================================================== [warn] [Appium] [info] [Appium] Appium v1.20.2 creating new AndroidUiautomator2Driver (v1.61.2) session [info] [Appium] Applying relaxed security to 'AndroidUiautomator2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure [debug] [BaseDriver] Creating session with MJSONWP desired capabilities: { [debug] [BaseDriver] "ensureWebviewsHavePages": true, [debug] [BaseDriver] "platformName": "Android", [debug] [BaseDriver] "newCommandTimeout": 0, [debug] [BaseDriver] "connectHardwareKeyboard": true [debug] [BaseDriver] } [warn] [BaseDriver] The following capabilities were provided, but are not recognized by Appium: [warn] [BaseDriver] connectHardwareKeyboard [info] [BaseDriver] Session created with session id: a7def776-063b-41be-b908-d8c598571316 [info] [UiAutomator2] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application[debug] [UiAutomator2] Deleting UiAutomator2 session [debug] [BaseDriver] Event 'newSessionStarted' logged at 1750921458808 (15:04:18 GMT+0800 (中国标准时间)) [debug] [MJSONWP] Encountered internal error running command: Error: Could not find 'adb.exe' in ["D:\\android-sdk-windows\\platform-tools\\adb.exe","D:\\android-sdk-windows\\emulator\\adb.exe","D:\\android-sdk-windows\\cmdline-tools\\latest\\bin\\adb.exe","D:\\android-sdk-windows\\tools\\adb.exe","D:\\android-sdk-windows\\tools\\bin\\adb.exe","D:\\android-sdk-windows\\adb.exe"]. Do you have Android Build Tools installed at 'D:\android-sdk-windows'? [debug] [MJSONWP] at ADB.getBinaryFromSdkRoot (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:125:11) [debug] [MJSONWP] at ADB.getSdkBinaryPath (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:44:10) [debug] [MJSONWP] at ADB.getAdbWithCorrectAdbPath (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:89:26) [debug] [MJSONWP] at Function.createADB (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-adb\lib\adb.js:56:3) [debug] [MJSONWP] at Object.createBaseADB (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:108:10) [debug] [MJSONWP] at Object.getDeviceInfoFromCaps (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:193:15) [debug] [MJSONWP] at AndroidUiautomator2Driver.startUiAutomator2Session (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:327:26) [debug] [MJSONWP] at AndroidUiautomator2Driver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:224:7) [debug] [MJSONWP] at AppiumDriver.createSession (D:\Appium-windows-1.20.2\resources\app\node_modules\appium\lib\appium.js:371:35) [info] [HTTP] <-- POST /wd/hub/session 500 258 ms - 574 [info] [HTTP]  [info] [HTTP] --> DELETE /wd/hub/session [info] [HTTP] {} [debug] [HTTP] No route found for /wd/hub/session [info] [HTTP] <-- DELETE /wd/hub/session 404 0 ms - 211 [info] [HTTP] 
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值