步骤1安装app-inspector
a先安装macaca
卸载原有的macaca:
1、npm uninstall macaca-cli -g
2、npm cache clean
安装npm install macaca-cli -g
安装完成后检查环境是否正常终端输入macaca doctor
只要全部显示为绿色为环境正常若不正常哪项显示为红色相应的解决可以网上找一下资料还是挺全的
b安装brewruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
c安装ios-webkit-debug-proxybrew install ios-webkit-debug-proxy
d安装macaca-iosnpm 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-deploybrew install ios-deploy
步骤2xcode打开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张图
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安装usbmuxdbrew install usbmuxd
b命令行执行iproxy 8900 8100或者是8100 8100
c启动app-inspecter