在模拟器成功获取到控件后,最后终于能够真机上使用app-inspector获取控件了
当前的环境为:mac 10.11.5,Xcode 8.2.1,iOS9.3.3
步骤1:安装app-inspector
a)先安装macaca
卸载原有的macaca:
1、npm uninstall macaca-cli -g
2、npm cache clean
安装:npm install macaca-cli -g
安装完成后,检查环境是否正常,终端输入:macaca doctor
只要全部显示为绿色为环境正常,若不正常,哪项显示为红色相应的解决,可以网上找一下资料,还是挺全的
b)安装brew:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
c)安装ios-webkit-debug-proxy:brew install ios-webkit-debug-proxy
d)安装macaca-ios:npm i macaca-ios -g
e) Macaca iOS 驱动调整为 USB 通信:brew install usbmuxd
f)安装app-inspector
卸载原有的app-inspector:
1、npm uninstall app-inspector -g
2、npm cache clean
安装:npm i app-inspector -g
安装成功后在终端中输入:
>>>cd /usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent
>>>mkdir -p Resources/WebDriverAgent.bundle
>>>sh ./Scripts/bootstrap.sh -d
若在执行以上3句命令行报错说找不到某些目录时的解决办法:
-
-
- 前往:https://github.com/facebook/WebDriverAgent 打包下载源码;
- 复制源码中【WebDriverAgentTests文件夹】、【Scripts文件夹】、【Cartfile文件】、【Cartfile.resolved文件】
- 粘贴到/usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent 目录下
- 重新执行以上3句命令行
-
g)安装ios-deploy:brew install ios-deploy
步骤2:xcode打开app-inspector中的WebDriverAgent工程:
路径为:/usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
1) 重新编绎WebDriverAgentLib:
修改:Bundle id,添加Team,选择WebDriverAgentLib并编辑(如下面3张图)
2)如以上步骤重新编绎WebDriverAgentRunner
3)选择WebDriverAgentUSBClient并编绎
4)按照步骤1)中修改:Bundle id,添加Team,重新编绎IntegrationApp,但是需要添加一步修改Product Name为: WebDriverAgentRunner-Runner
此时选中IntegrationApp并编绎时,可能会报错:找不到info.plist (这个是因为工程中缺少一个目录文件:WebDriverAgentTests)
解决办法:进入appium的安装路径中WebDriverAgent工程(/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/)中拷备该目录文件放到app-inspectorWebDriverAgent工程中
再次编绎,若报错新问题: Main storyboard file base name 相关的问题的问题
解决办法:进入IntegrationApp>info>Custom iOS Target Properties中删除Main storyboard file base name的配置
若遇到其它问题,继续解决,直到可以正确编绎为止
建议:UnitTests、IntegrationTests 也如1)修改:Bundle id,添加Team,操作后最后再编绎 IntegrationApp
步骤3:打开终端,输入 :macaca server --verbose
出现以下内容
>> request.js:24:12 [master] pid:34557 get remote update info failed.
>> index.js:17:12 [master] pid:34558 webdriver server start with config:
{ port: 3456,
verbose: true,
always: true,
ip: '10.1.18.165',
host: 'XXX.local',
loaded_time: '2017-02-16 14:18:28' }
>> middlewares.js:17:10 [master] pid:34558 base middlewares attached
>> router.js:127:10 [master] pid:34558 router set
>> webdriver sdk launched
步骤4:打开终端,输入:app-inspector -u 真机设备UDID --verbose
运行过程中会在手机上安装WebDriverAgent的APP(记得要去信任证书才行,若第一次失败了,信任证书后重新执行终端命令)并启动,稍等一会儿会被置入后台,此时会自动打开一个网页,此时就会显示出当前的设备UI界面
XXXdeMacbook-Air:~ XXX$ app-inspector -u 设备udid --verbose >> server.js:16:12 [master] pid:34571 server start with config: { port: 5678, verbose: true, udid: '设备udid', ip: '10.1.18.165', host: 'XXXdeMacbook-Air.local', loaded_time: '2017-02-16 14:18:50' } >> app-inspector.js:42:10 [master] pid:34571 server start at: http://10.1.18.165:5678 >> xctest-client.js:56:14 [master] pid:34571 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:34571 xcode version: 8.2.1 >> WebDriverAgent version: 1.0.41 >> xctest-client.js:170:14 [master] pid:34571 2017-02-16 14:18:52.484 xcodebuild[34577:1239191] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: /Users/XXX/Library/Developer/Xcode/DerivedData/WebDriverAgent-fufzddftjuaziqbqsgzxfgnhxfhf/Logs/Test/A0E63772-010C-42AA-B667-75A42C3DD7B7/Session-WebDriverAgentRunner-2017-02-16_141852-uYtrIc.log 2017-02-16 14:18:52.484 xcodebuild[34577:1239151] [MT] IDETestOperationsObserverDebug: (52E7D9BD-BCAA-43C6-A3FC-CA664A377214) Beginning test session WebDriverAgentRunner-52E7D9BD-BCAA-43C6-A3FC-CA664A377214 at 2017-02-16 14:18:52.483 with Xcode 8C1002 on target <DVTiOSDevice: 0x7f91cccd6550> { deviceSerialNumber: XXXXXXXX identifier: 设备udid deviceClass: iPhone deviceName: 0112iPhone deviceIdentifier: 设备udid productVersion: 9.3.3 buildVersion: 13G34 deviceSoftwareVersion: 9.3.3 (13G34) deviceArchitecture: arm64 deviceTotalCapacity: 122562965504 deviceAvailableCapacity: 103091081216 deviceIsTransient: NO ignored: NO deviceIsBusy: NO deviceIsActivated: YES deviceActivationState: Activated deviceType: <DVTDeviceType:0x7f91cccbf7b0 Xcode.DeviceType.iPhone> supportedDeviceFamilies: ( 1 ) applications: (null) provisioningProfiles: (null) activityProgress: -2 activityTitle: hasInternalSupport: NO isSupportedOS: YES developerDiskMountError: (null) (null) } (9.3.3 (13G34)) >> xctest-client.js:171:14 [master] pid:34571 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj >> xctest-client.js:170:14 [master] pid:34571 MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with: state->old_bundle: /var/folders/f_/c2d1j2c11nbf84jj566wzx000000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/97bda29204e9bab8b0e965b05a9ff4be/2abc700de7224db44d77699768cc4c441c0fdc91/WebDriverAgentRunner-Runner.app state->new_bundle: /Users/XXX/Library/Developer/Xcode/DerivedData/WebDriverAgent-fufzddftjuaziqbqsgzxfgnhxfhf/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app state->dst_bundle: /var/folders/f_/c2d1j2c11nbf84jj566wzx000000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.djQMjR/WebDriverAgentRunner-Runner.app_sparse.ipa/Payload//WebDriverAgentRunner-Runner.app, binaryDiff flag: FALSE dst_ipa: /var/folders/f_/c2d1j2c11nbf84jj566wzx000000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.djQMjR/WebDriverAgentRunner-Runner.app_sparse.ipa >> xctest-client.js:171:14 [master] pid:34571 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj >> xctest-client.js:170:14 [master] pid:34571 __MDMDirectoryDiff_block_invoke.37:1473 calling writeDictToFile with: /var/folders/f_/c2d1j2c11nbf84jj566wzx000000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.djQMjR/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist >> xctest-client.js:171:14 [master] pid:34571 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/.1.0.41@webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj >> xctest-client.js:170:14 [master] pid:34571 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/f_/c2d1j2c11nbf84jj566wzx000000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.djQMjR/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist >> xctest-client.js:171:14 [master] pid:34571 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:34571 Proxy: /session:POST to http://127.0.0.1:8900/session:POST with body: {"desiredCapabilities":{}} >> proxy.js:84:20 [master] pid:34571 Got response with status 200: {"value":"'bundleId' desired capability not provided","sessionId":null,"status":13} >> iOS device started: 2abc700de7224db44d77699768cc4c441c0fdc91 >> inspector start at: http://10.1.18.165:5678 <-- GET / >> ios.js:67:10 [master] pid:34571 Dump iOS XML success, save to /usr/local/lib/node_modules/app-inspector/.temp/ios.json --> GET / 200 <-- GET / >> ios.js:67:10 [master] pid:34571 Dump iOS XML success, save to /usr/local/lib/node_modules/app-inspector/.temp/ios.json --> GET / 200 <-- GET / >> ios.js:67:10 [master] pid:34571 Dump iOS XML success, save to /usr/local/lib/node_modules/app-inspector/.temp/ios.json --> GET / 200
错误解决:
1) xctest client proxy error with: Error: socket hang up问题:
a)安装usbmuxd:brew install usbmuxd
b)命令行执行:iproxy 8900 8100(或者是8100 8100)
c)启动app-inspecter