以下为虚拟机获取控件的方法,因真机一直调试不过,后面如果调通再更新
第一步:配置App inspecter 环境
https://macacajs.github.io/app-inspector/cn/
如果出现问题,可以在网上找一下解决办法,相关的文档还是很多的
第二步:启动XCUIRunner
终端中输入:xcodebuild -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=设备udid test
2017-02-13 14:25:10.876 XCTRunner[4821:221158] Running tests... 2017-02-13 14:25:11.664 XCTRunner[4821:221158] Continuing to run tests in the background with task ID 1 Test Suite 'All tests' started at 2017-02-13 14:25:12.250 Test Suite 'WebDriverAgentLib.framework' started at 2017-02-13 14:25:12.252 Test Suite 'WebDriverAgentLib.framework' passed at 2017-02-13 14:25:12.253. Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds Test Suite 'WebDriverAgentRunner.xctest' started at 2017-02-13 14:25:12.254 Test Suite 'UITestingUITests' started at 2017-02-13 14:25:12.255 Test Case '-[UITestingUITests testRunner]' started. t = 0.00s Start Test at 2017-02-13 14:25:12.257 t = 0.00s Set Up 2017-02-13 14:25:12.261 XCTRunner[4821:221158] Built at Feb 13 2017 14:01:24 2017-02-13 14:25:12.282 XCTRunner[4821:221158] ServerURLHere->http://10.1.18.130:8100<-ServerURLHere
第三步:终端输入:macaca server --verbose
XXXMacbook-Air:~ XXX$ macaca server --verbose
>> request.js:24:12 [master] pid:4611 get remote update info failed.
>> index.js:17:12 [master] pid:4612 webdriver server start with config:
{ port: 3456,
verbose: true,
always: true,
ip: '10.1.18.130',
host: 'XXXMacbook-Air.local',
loaded_time: '2017-02-13 14:17:31' }
>> middlewares.js:17:10 [master] pid:4612 base middlewares attached
>> router.js:127:10 [master] pid:4612 router set
>> webdriver sdk launched
获取到显示出的值中的port: 3456,应用在第4步
第四步:终端中输入:app-inspector -u 设备udid --verbose -p 3456
XXXdeMacbook-Air:~ XXX$ app-inspector -u 4A8570B0-A635-49F8-8FAC-62F9AD83E507 --verbose -p 3456 >> port: 3456 was occupied, changed port: 54055 >> server.js:16:12 [master] pid:4626 server start with config: { port: 54055, verbose: true, udid: '4A8570B0-A635-49F8-8FAC-62F9AD83E507', ip: '10.1.18.130', host: 'XXXdeMacbook-Air.local', loaded_time: '2017-02-13 14:18:20' } >> app-inspector.js:42:10 [master] pid:4626 server start at: http://10.1.18.130:54055 >> xctest-client.js:56:14 [master] pid:4626 project path: /usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj >> xctest-client start with port: 8900 >> xctest-client.js:233:14 [master] pid:4626 xcode version: 8.2.1 >> WebDriverAgent version: 1.0.41 >> xctest-client.js:170:14 [master] pid:4626 2017-02-13 14:18:22.478 xcodebuild[4630:211110] [MT] IDETestOperationsObserverDebug: (856362DB-B5B9-43BE-B1F8-9DA8791A8F27) Beginning test session WebDriverAgentRunner-856362DB-B5B9-43BE-B1F8-9DA8791A8F27 at 2017-02-13 14:18:22.477 with Xcode 8C1002 on target <DVTiPhoneSimulator: 0x7f96acdf9ef0> { SimDevice: SimDevice : iPhone 6 (4A8570B0-A635-49F8-8FAC-62F9AD83E507) : state={ Booted } deviceType={ SimDeviceType : com.apple.CoreSimulator.SimDeviceType.iPhone-6 } runtime={ SimRuntime : 10.2 (14C89) - com.apple.CoreSimulator.SimRuntime.iOS-10-2 } } (10.2 (14C89)) 2017-02-13 14:18:22.478 xcodebuild[4630:211111] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: /Users/XXX/Library/Developer/Xcode/DerivedData/WebDriverAgent-fufzddftjuaziqbqsgzxfgnhxfhf/Logs/Test/A136548E-50C1-4E43-A286-0F2080A2F61F/Session-WebDriverAgentRunner-2017-02-13_141822-MKeuF9.log >> xctest-client.js:171:14 [master] pid:4626 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj >> proxy.js:56:14 [master] pid:4626 Proxy: /session:POST to http://10.1.18.130:8900/session:POST with body: {"desiredCapabilities":{}} >> proxy.js:84:20 [master] pid:4626 Got response with status 200: {"value":"'bundleId' desired capability not provided","sessionId":null,"status":13} >> iOS device started: 4A8570B0-A635-49F8-8FAC-62F9AD83E507 >> inspector start at: http://10.1.18.130:54055 <-- GET / >> ios.js:67:10 [master] pid:4626 Dump iOS XML success, save to /usr/local/lib/node_modules/app-inspector/.temp/ios.json --> GET / 200
inspector start at: http://10.1.18.130:54055会直接打开一个网页: