Appium 启动 WebDriverAgent 后再启动 appium,运行脚本一直卡在 Waiting for WebDriverAgent to start on device

yefengjun · 2017年02月07日 · 最后由 回复于 2017年09月19日 · 3413 次阅读

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 一直等着也不往下进行了

共收到 13 条回复 时间 点赞

额,大神们帮忙看看吧...感谢!

😭 😭 😭 网上也没看到什么解决办法

appium github 官方有人问这个,我看到的解决方案是这样。我按此操作之后就可以了。注意第一步要进入到 appium/node_modules 文件夹内。

1.sudo npm install appium-xcuitest-driver@2.5.2 (inside appium/node_modules)

2.cd appium-xcuitest-driver/WebDriverAgent/

3.mkdir -p Resources/WebDriverAgent.bundle

4.sh ./Scripts/bootstrap.sh -d
5.Go to the appium-xcuitest-driver xcode project and check the automatic sign in for the Lib/Runner/IntegrationApp

#3 楼 @Noble-Six 谢谢!我去试一下。

#3 楼 @Noble-Six 这个问题解决了,感谢!

修改一下 markdown 格式啊

楼主 你怎么解决的 上面办法还是不行啊

wda 获取到 ip 地址后,通过浏览器打开http://192.168.32.205:8100/status,发现打不开,请问是什么原因呢

纪小莉 回复

报啥错呢?

蒋思凯 回复

就是照着 3 楼的方法做的

yefengjun 回复

我不行,后来怎么解决的?[debug] [XCUITest] Failed to create WDA session. Retrying...
[debug] [BaseDriver] Event 'wdaSessionAttempted' logged at 1491644589377 (17:43:09 GMT+0800 (CST))
[debug] [XCUITest] Sending createSession command to WDA
一直这样

纪小莉 回复

问题解决了吗?我也是打不开

@yefnegjun 是不是每次运行脚本的话就得执行一次 xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=d69d11788a251a64fc31dfbc93c9053cfca5cbca' test。我每次不执行这句就运行不了

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