Appium 1.6.3 在Xcode 8 (真機)測試環境搭建經驗總結java
關於 Appium 1.6.3 在Xcode 8, 1真機上環境搭建問題更多,寫此文章,供你們參考,讓你們少走彎路。node
在開始iOS真機測試以前,請你們務必 將 Appium 1.6.3 + xcode 8 在iOS模擬器上的環境搭建OK,請參見個人上一篇博文:Appium 1.6.3在Xcode 8, iOS 10.2(模擬器)測試環境搭建經驗總結 ios
若是iOS模擬器上的環境OK,再來真機上搭建,要否則 你仍是放棄吧。
npm
進入正題 :swift
首先,上邊文章:Appium 1.6.3 在Xcode 8, iOS 10.2(模擬器)試環境搭建經驗總結 中 第1、第2、第三步 必須結束掉,而後開始,務必!xcode
1、安裝相關依賴app
(1)安裝ios-deploy oop
npm i -g ios-deploy測試
否則會執行錯誤會報錯:ui
[XCUITest] Could not initialize ios-deploy make sure it is installed and works on your system
[XCUITest] Error: Could not initialize ios-deploy make sure it is installed and works on your system
at XCUITestDriver.getIDeviceObj$ (../../lib/driver.js:685:13)
(2)安裝libimobiledevice
brew install libimobiledevice --HEAD
2、安裝 appium-xcuitest-driver (先卸載在從新安裝新版本2.5.3)
緣由:appium 默認安裝的appium-xcuitest-driver版本有點老,貌似是 2.4.0的版本,老的版本問題,運行測試的時候會提示
debug] [WebDriverAgent] Device: Mar 29 15:29:21 Cheersde-iPhone XCTRunner[2848] <Notice>: Running tests...
[debug][WebDriverAgent] Device: Mar 29 15:29:22 Cheersde-iPhone XCTRunner[2848] <Notice>: Continuing to run tests in the background with task ID 1
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
致使被測試的app launch不起來,一直卡在 [debug][XCUITest] Waiting for WebDriverAgent server to finish loading... 這塊
而新的版本appium-xcuitest-driver 2.5.3 就解決了這個問題。
安裝方法:
cd /usr/local/lib/node_modules/appium
npm uninstall appium-xcuitest-driver 先卸載
npm install appium-xcuitest-driver@2.5.3 從新安裝 2.5.3
3、編譯 WebDriverAgentRunner,並安裝到 真機(個人是iPhone 5s)
說明:appium是經過手機上WebDriverAgentRunner,來運行測試的,沒有這個 在真機上沒有辦法測試(模擬器上須要着個,不過會自動安裝)
3.1用Xcode打開WebDriverAgent,而且編譯(編譯以前須要一些設置)
(1)進入WebDriverAgent 文件夾,可用以下方法
目錄是 /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
(2)選中WebDriverAgent.xcodeproj 文件,用xcode打開,並作如圖設置。
見圖
編譯WebDriverAgent 點擊編譯按鈕,見上圖。 提示 Build Success 後編譯結束。
3.2 在手機上安裝WebDriverAgent (手機和MAC都在同一個網段下)
(1)鏈接手機和Mac電腦
(2)終端 進入WebDriverAgent文件夾
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
執行:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=真機的udid'test
這時候,會在手機上安裝 WebDriverAgentRunner 的app。
請注意手機,若是提示是不收信任的開發者,請在設置-通用-設備管理(描述文件)信任你的apple id就能夠了。
再次運行
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=真機的udid'test
這樣WebDriverAgentRunner在手機上就安裝成功了。
4、啓動appium
命令行執行 appium
5、編寫一個簡單的測試用例,Java編寫(基於TESTNG):
而後右鍵,run as testng,就能夠在真機上看到效果
參考文章:https://testerhome.com/topics/6962