前言:
Appium 是一個自動化測試開源工具角雷,支持 iOS 平臺和 Android 平臺上的原生應(yīng)用,web 應(yīng)用和混合應(yīng)用老赤。
本次環(huán)境配置相關(guān):
macOS:10.13.4
Appium-desktop:1.6.1
Xcode:9.3.1
一椿猎、環(huán)境配置
1危尿、 安裝homebrew:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、 安裝libimobiledevice:
$ brew install libimobiledevice --HEAD
3朗和、 安裝carthage:
$ brew install carthage
4错沽、安裝node:
$ brew install node
5、安裝npm:
$ brew install npm
6眶拉、安裝ios-deploy:
$ npm install -g ios-deploy
8千埃、安裝xcpretty:
$ gem install xcpretty
9、安裝appium忆植,appium-doctor
進入官網(wǎng)放可,下載Appium-1.6.1.dmg,安裝即可朝刊。
當然你可以使用命令:npm install -g appium來安裝appium耀里,但是后面就會各種報錯!J懊ァ(別問我是怎么知道的冯挎,我搞了2天。)
$ npm install -g appium-doctor
10痪枫、使用appium-doctor 檢查Appium iOS環(huán)境環(huán)境
appium-doctor --ios
info AppiumDoctor Appium Doctor v.1.4.3
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ? The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ? Node version is 10.1.0
info AppiumDoctor ? Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor ? Xcode Command Line Tools are installed.
info AppiumDoctor ? DevToolsSecurity is enabled.
info AppiumDoctor ? The Authorization DB is set up properly.
info AppiumDoctor ? Carthage was found at: /usr/local/bin/carthage
info AppiumDoctor ? HOME is set to: /Users/wangjuan
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor
二织堂、安裝WebDriverAgent
1叠艳、進入appium安裝目錄下WebDriverAgent文件夾奶陈,具體路徑參照自己的路徑易阳,可以通過find命令查找
cd /Applications/Appium.app/Contents/Resources/app
/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
2、在WebDriverAgent目錄下執(zhí)行以下命令
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh
3吃粒、編譯WebDriverAgent.xcodeproj
注意??:進入項目后要編輯一些內(nèi)容潦俺,請無比按照步驟全部修改。步驟見下圖P觳事示!
1、TARGETS->WebDriverAgentLib的Bundle Identifier更改為自己命名的Identifier僻肖。(所有Identifier注意保持一致Pぞ簟!)
2臀脏、TARGETS->WebDriverAgentLib的Signing選擇使用個人的證書劝堪。
3、TARGETS->WebDriverAgentRunner的Signing選擇使用個人的證書揉稚。
4秒啦、PROJECT->WebDriverAgent的Product Bundle Identifier更改為自己命名的Identifier。(所有Identifier注意保持一致2缶痢S嗑场)
5、TARGETS->WebDriverAgentLib的Product Bundle Identifier更改為自己命名的Identifier灌诅。(所有Identifier注意保持一致7祭础!)
6猜拾、TARGETS->WebDriverAgentRunner的Product Bundle Identifier更改為自己命名的Identifier即舌。(所有Identifier注意保持一致!9卮)
7侥涵、Device選擇已連接的測試機
8、點擊build按鈕來測試宋雏,按照步驟設(shè)置后芜飘,可build succeeded~
如果沒有報錯證明安裝成功嗦明,同時手機上會安裝一個WebDriverAgent軟件。需要在手機設(shè)置->通用->設(shè)備管理->信任開發(fā)者蚪燕。如下圖:9、測試機上安裝證書磨总,執(zhí)行以下命令:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=測試機的udid' test
三娶牌、Appium Client端
Appium Client有Ruby奔浅,Python,Java三個版本诗良,可自行選擇自己喜歡的安裝即可汹桦,本次只針對Python版安裝:
pip install Appium-Python-Client
以上,接下來可以定位元素鉴裹,推薦使用App Inspector舞骆,開始iOS自動化之旅吧~~