1. 程式人生 > >Xcode9.0+appium1.6.5真機環境運行app及遇坑知多少

Xcode9.0+appium1.6.5真機環境運行app及遇坑知多少

xc0de9.0 appium1.6.5 真機測試app ios app真機測試 ios app自動化測試

Mac下把appium自動化環境搭建好後,進行真機測試時會碰到相當多的坑,

下面給大家一一列出來並附上解決方法。

一、selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system

這是沒有安裝ideviceinstaller導致。

解決方法:

1.解決方法在終端執行,先安裝brew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.裝好brew後,在執行下面指令裝ideviceinstaller:

brew install ideviceinstaller

二、

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not find Automation.tracetemplate in any of the followinglocations /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate,/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate

報錯原因是沒有安裝Automation.tracetemplate模塊。我用的是appium1.5.3 、Xcode8。

Xcode8移除了UI Automation

解決方法:

裝個桌面版的appium 1.6.5可以解決這個問題。到我的網盤下載。

鏈接:http://pan.baidu.com/s/1qYPYGd2 密碼:f2o7

查看自帶的appium-xcuitest-driver版本,npm list查看,版本如果不是2.5.3或更新請卸載再裝(自帶的版本太老會導致app launch不起來,一直在等待)

卸載:npm uninstall appium-xcuitest-driver

安裝:npm install [email protected]

三、通過指令安裝brew install libimobiledevice

四、通過指令安裝npm install -g ios-deploy

不安裝會報以下錯誤:

[XCUITest] Could notinitialize ios-deploy make sure it is installed and works on your system

五、指令安裝gem install xcpretty這可以使xcode輸出更合理

六、 指令安裝npm i -g webpack

這和WebDriverAgent相關,沒有這個 會報錯:Unable to create new remotesession

七、selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65

WebDriverAgent報錯,需要安裝。

解決方法:

1.必須先安裝Carthage,執行指令:brew installCarthage

2.安裝WebDriverAgent:

cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent(自己的appium路徑在哪就去哪找)

先執行mkdir -pResources/WebDriverAgent.bundle

再執行sh ./Scripts/bootstrap.sh(執行這個指令前最好鏈接vpn不然等待非常久)

編譯WebDriverAgent.xcodeproj(以上這個是安裝自帶的,大家不要裝)

自帶的webdriveragent有問題,自己下一個,不然用自帶的在xcode上編譯報各種錯誤。。。搞死你。。。。 我這裏被折騰了1天多。。。。各種百度各種谷歌。按下面解決:

cd ~

git clone https://github.com/facebook/WebDriverAgent.git

cd WebDriverAgent

mkdir -p Resources/WebDriverAgent.bundle

sh ./Scripts/bootstrap.sh

然後進入到appium-xcuitest-driver路徑

cd/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/

rm –rf WebDriverAgent(移除自帶的,當然如果沒有安裝自帶的就不用執行這個指令)

ln –s ~/WebDriverAgent WebDriverAgent(引用自己下載的webdriveragent)

編譯WebDriverAgent.xcodeproj

編譯要修改的地方:

1. 在xcode添加開發者賬號:

技術分享


2. 設置WebDriverAgentLib-General選項:

技術分享


3. 設置WebDriverAgentLib-Build Settings選項

技術分享


這裏面的Product Bundle Identifler一定要改一下,不能完全一樣。可以把facebook改成自己的名字拼音

4. 設置WebDriverAgentRunner---General和Build Settings選項

和設置webdriveragentlig的一樣,就不截圖。

1. General裏選擇signing裏勾選Automatically manage signing選項,並且選上自己的開發賬號。

2. Build Settings裏修改一下Bundle Identifier的名稱即可。

接下來就是連接真機編譯,真機編譯後要安裝到手機,安裝到手機有兩種方法:

一、用指令

cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

執行:

xcodebuild -projectWebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=真機的udid‘test

二、在Xcode裏面執行test安裝

安裝過程會王手機裏安裝一個webdriveragent的app,無圖標,打開一般都是黑色。

安裝過程會出現自動打開和退出這個app的現象。

之後就可以運行python代碼了。

註:如果按以上執行還不行就換個usb口,小的就是換了個usb口就可以運行真機上的app了。切記切記!!

QQ交流群610845268


本文出自 “IT蟲” 博客,請務必保留此出處http://laomomo.blog.51cto.com/6595318/1970966

Xcode9.0+appium1.6.5真機環境運行app及遇坑知多少