Appium1.6.4-beta iPhone真機控件獲取 app-inspector


在模擬器成功獲取到控件后,最后終於能夠真機上使用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句命令行報錯說找不到某些目錄時的解決辦法:

      1. 前往:https://github.com/facebook/WebDriverAgent 打包下載源碼;
      2. 復制源碼中【WebDriverAgentTests文件夾】、【Scripts文件夾】、【Cartfile文件】、【Cartfile.resolved文件】
      3. 粘貼到/usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent 目錄下
      4. 重新執行以上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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM