前情提要
之前在上家公司編譯過WebdriverAgent到真機(jī)栅组,當(dāng)時沒有遇到那么多坑,這陣子在新公司再次編譯WebdriverAgent到真機(jī)時遇到n多令人崩潰的問題棉磨,因此特發(fā)此文子檀,以便需要時再看浴韭。
版本
Appium-1.7.1.dmg Mac桌面版
Xcode9.4
真機(jī)系統(tǒng)版本 iOS 10.1.1
過程
1.基礎(chǔ)環(huán)境
首先當(dāng)然是安裝好Appium iOS相關(guān)環(huán)境客叉,可參考這里搭建環(huán)境。
2.WebdriverAgent下載以及依賴環(huán)境安裝
基礎(chǔ)環(huán)境搭建好之后,下載最新的WebdriverAgent項目到本地兼搏,進(jìn)入下載的工程目錄文件夾卵慰,執(zhí)行腳本安裝依賴(切記此時先不要移動或拷貝文件夾到appium安裝目錄下)。
? WebDriverAgent git:(master) ? cd WebdriverAgent #切換到WebdriverAgent目錄下
? WebDriverAgent git:(master) ? sudo mkdir -p Resources/WebDriverAgent.bundle #創(chuàng)建資源文件夾
? WebDriverAgent git:(master) ? sudo sh ./Scripts/bootstrap.sh #執(zhí)行腳本安裝wda依賴
當(dāng)出現(xiàn)類似如下提示時佛呻,表示依賴環(huán)境安裝成功裳朋。
之所以先不要移動或拷貝文件夾到appium安裝目錄,是因為移動到appium安裝目錄下之后吓著,安裝依賴時會報各種錯鲤嫡,難以解決。
3.WebdriverAgent項目編譯
備份或刪除原來appium自帶的WebdriverAgent绑莺,我的路徑是:
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
PS命令行安裝的appium路徑為:
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
備份或者刪除完成后暖眼,將第二步下載以及安裝好依賴環(huán)境的WebdriverAgent工程拷貝至上述目錄中。雙擊WebDriverAgent.xcodeproj纺裁,在Xcode中打開WebdriverAgent項目诫肠。
這里我們需要編譯兩個東西,一個是WebDriverAgentLib欺缘,一個是WebdriverAgentRunner栋豫。在編譯之前請在Xcode中登錄開發(fā)者賬號。
WebDriverAgentLib編譯步驟如下:
WebdriverAgentRunner編譯步驟如下:
4.編譯WebdriverAgent到真機(jī)
切換到WebdriverAgent所在目錄谚殊,執(zhí)行如下命令:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=真機(jī)udid' test
首次安裝可能會失敗丧鸯,原因是我們手機(jī)并并沒有信任這個apple id的開發(fā)者,到設(shè)置-通用-設(shè)備管理(描述文件) 信任你的apple id就可以了嫩絮。再次運行上述命令丛肢,看到如下圖,就成功了絮记,此時手機(jī)上會出現(xiàn)WebdriverAgent圖標(biāo)摔踱。
真機(jī)udid可以通過:idevice_id -l獲取
參考文章
https://www.cnblogs.com/baconLiu/p/6861431.html
http://www.cnblogs.com/we8fans/p/7384291.html
https://testerhome.com/topics/6962
https://github.com/appium/appium-desktop/releases?after=v1.8.0
https://www.cnblogs.com/yuhanle/articles/8213675.html
https://blog.csdn.net/qq_34890427/article/details/75045028?fps=1&locationNum=10
https://github.com/facebook/WebDriverAgent/wiki/How-To-Achieve-The-Best-Lookup-Performance
https://testerhome.com/topics/7192