Appium 版本是 1.6.3
设备是 iphone6 IOS9.3.4
之前用 1.5.3 版本的 Appium 已经可以在真机上跑通自己项目的自动化脚本了,想换 1.6.3 版本试一下 WebDriverAgent
已经照着https://testerhome.com/topics/4904 安装好 WebDriverAgent 了
脚本中初始化的代码如下:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.3.4");
capabilities.setCapability("deviceName", "iPhone");
capabilities.setCapability("udid", "d69d11788a251a64fc31dfbc93c9053cfca5cbca");
capabilities.setCapability("app", "/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app");
wd = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities) 

说下步骤:
在终端中启动 WebDriverAgent

cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=d69d11788a251a64fc31dfbc93c9053cfca5cbca' test

之后启动 Appium 服务
运行日志如下

bogon:WebDriverAgent yefengjun$ sh ./Scripts/bootstrap.sh
-e Fetching dependencies
-e Building Inspector
Creating bundle directory...
Fetching Inspector dependencies...
npm WARN react-treeview@0.4.6 requires a peer of react@>=0.14.0 but none was installed.
npm WARN web-driver-inspector@1.0.0 No repository field.
Building Inspector...

> web-driver-inspector@1.0.0 build /Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Inspector
> webpack --progress --colors

Hash: 30b1e7620a314d43cf44  
Version: webpack 1.14.0
Time: 4637ms
       Asset    Size  Chunks             Chunk Names
inspector.js  700 kB       0  [emitted]  main
   [0] multi main 28 bytes {0} [built]
    + 182 hidden modules
Done
bogon:WebDriverAgent yefengjun$ cd  /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
bogon:WebDriverAgent yefengjun$ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=d69d11788a251a64fc31dfbc93c9053cfca5cbca' test
.....
MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/m4/ns53sgdd15z_7qf85lwlt_sm0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/959e1e4a9e19081b7665aadde109793a/d69d11788a251a64fc31dfbc93c9053cfca5cbca/WebDriverAgentRunner-Runner.app
state->new_bundle: /Users/yefengjun/Library/Developer/Xcode/DerivedData/WebDriverAgent-ghzpiffgtudyzmfauiwmfrzehqnx/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app
state->dst_bundle: /var/folders/m4/ns53sgdd15z_7qf85lwlt_sm0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.adbSg1/WebDriverAgentRunner-Runner.app_sparse.ipa/Payload//WebDriverAgentRunner-Runner.app, binaryDiff flag: FALSE
    dst_ipa: /var/folders/m4/ns53sgdd15z_7qf85lwlt_sm0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.adbSg1/WebDriverAgentRunner-Runner.app_sparse.ipa
__MDMDirectoryDiff_block_invoke.37:1473 calling writeDictToFile with: /var/folders/m4/ns53sgdd15z_7qf85lwlt_sm0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.adbSg1/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/m4/ns53sgdd15z_7qf85lwlt_sm0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.adbSg1/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
2017-02-07 15:41:59.324 XCTRunner[476:140826] Running tests...
2017-02-07 15:42:00.109 XCTRunner[476:140826] Continuing to run tests in the background with task ID 1
Test Suite 'All tests' started at 2017-02-07 15:42:00.815
Test Suite 'WebDriverAgentRunner.xctest' started at 2017-02-07 15:42:00.818
Test Suite 'UITestingUITests' started at 2017-02-07 15:42:00.821
Test Case '-[UITestingUITests testRunner]' started.
    t =     0.00s     Start Test at 2017-02-07 15:42:00.825
    t =     0.01s     Set Up
2017-02-07 15:42:00.833 XCTRunner[476:140826] Built at Feb  7 2017 11:27:32
2017-02-07 15:42:00.871 XCTRunner[476:140826] ServerURLHere->http://10.0.137.89:8100<-ServerURLHere
2017-02-07 15:42:00.872 XCTRunner[476:140826] Listening on USB
    t =    13.60s     Find the Application "local.pid.477" 0x14579c5f0
    t =    13.61s         Snapshot accessibility hierarchy for local.pid.477
^C** BUILD INTERRUPTED **

bogon:WebDriverAgent yefengjun$ appium
[Appium] Welcome to Appium v1.6.3 (REV f85a57bcde189999b810100fe2a2883a071b6d54)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.company.AppName","appActivity":"com.company.AppName.AppMainActivity","app":"/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app","appium-version":"1.0","platformVersion":"9.3.4","automationName":"XCUITest","platformName":"iOS","udid":"d69d11788a251a64fc31dfbc93c9053cfca5cbca","deviceName":"iPhone"}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appPackage":"com.company.AppName","appActivity":"com.company.AppName.AppMainActivity","app":"/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app","appium-version":"1.0","platformVersion":"9.3.4","automationName":"XCUITest","platformName":"iOS","udid":"d69d11788a251a64fc31dfbc93c9053cfca5cbca","deviceName":"iPhone"},null,null,null,null]
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium]   appPackage: 'com.company.AppName'
[Appium]   appActivity: 'com.company.AppName.AppMainActivity'
[Appium]   app: '/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app'
[Appium]   appium-version: '1.0'
[Appium]   platformVersion: '9.3.4'
[Appium]   automationName: 'XCUITest'
[Appium]   platformName: 'iOS'
[Appium]   udid: 'd69d11788a251a64fc31dfbc93c9053cfca5cbca'
[Appium]   deviceName: 'iPhone'
[debug] [XCUITest] XCUITestDriver version: 2.4.2
[BaseDriver] The following capabilities were provided, but are not recognized by appium: appPackage, appActivity, appium-version.
[BaseDriver] Session created with session id: 10fc29d0-11b2-4f0b-bbca-874a4703a962
[debug] [XCUITest] Xcode version set to '8.1'
[debug] [XCUITest] iOS SDK Version set to '10.1'
[debug] [XCUITest] Available devices: d69d11788a251a64fc31dfbc93c9053cfca5cbca
[debug] [XCUITest] Creating iDevice object with udid d69d11788a251a64fc31dfbc93c9053cfca5cbca
[XCUITest] Determining device to run tests on: udid: 'd69d11788a251a64fc31dfbc93c9053cfca5cbca', real device: true
[BaseDriver] Using local app '/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app'
[debug] [XCUITest] Checking whether app '/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app' is actually present
[debug] [XCUITest] App is present
[debug] [ios-app-utils] Getting bundle ID from app '/Users/yefengjun/Downloads/Products Bundle ID:com.JDVideo/Debug-iphoneos/JDLive.app': 'com.JDVideo'
[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'
[XCUITest] Setting up real device
[debug] [XCUITest] App is already installed.
[debug] [XCUITest] Full reset not requested. No need to install.
[XCUITest] Using WDA path: '/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: /usr/local/bin/carthage
[debug] [XCUITest] Killing hanging processes
[debug] [XCUITest] Using real device logger 'idevicesyslog'
[debug] [XCUITest] Beginning test with command 'xcodebuild build test -project /Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=d69d11788a251a64fc31dfbc93c9053cfca5cbca -configuration Debug' in directory '/Users/yefengjun/Downloads/appium/node_modules/appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Waiting for WebDriverAgent to start on device
[debug] [XCUITest] Log file for xcodebuild test: /Users/yefengjun/Library/Developer/Xcode/DerivedData/WebDriverAgent-ghzpiffgtudyzmfauiwmfrzehqnx/Logs/Test/A7DFA1D3-BC99-4D29-BD3F-6ACA03B8A0FA/Session-WebDriverAgentRunner-2017-02-07_154451-bM0xU4.log

最后卡在 Waiting for WebDriverAgent to start on device 一直等着也不往下进行了


↙↙↙阅读原文可查看相关链接,并与作者交流