Appium 是一個自動化測試開源工具,支持 iOS 平臺和 Android 平臺上的原生應用,web 應用和混合應用。node
本次環境配置相關:
macOS:10.13.4
Appium-desktop:1.6.1
Xcode:9.3.1
---ios
一、 安裝homebrew:git
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"github
二、 安裝libimobiledevice:web
$ brew install libimobiledevice --HEADnpm
三、 安裝carthage:bootstrap
$ brew install carthagexcode
四、安裝node:ruby
$ brew install nodeapp
五、安裝npm:
$ brew install npm
六、安裝ios-deploy:
$ npm install -g ios-deploy
八、安裝xcpretty:
$ gem install xcpretty
九、安裝appium,appium-doctor
進入官網,下載Appium-1.6.1.dmg,安裝便可。
固然你能夠使用命令:npm install -g appium來安裝appium,可是後面就會各類報錯!!(別問我是怎麼知道的,我搞了2天。)
$ npm install -g appium-doctor
十、使用appium-doctor 檢查Appium iOS環境環境
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
一、進入appium安裝目錄下WebDriverAgent文件夾,具體路徑參照本身的路徑,能夠經過find命令查找
cd /Applications/Appium.app/Contents/Resources/app
/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
二、在WebDriverAgent目錄下執行如下命令
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh
三、編譯WebDriverAgent.xcodeproj
Xcode打開當前目錄下的WebDriverAgent.xcodeproj文件
注意⚠️:進入項目後要編輯一些內容,請無比按照步驟所有修改。步驟見下圖!!
一、TARGETS->WebDriverAgentLib的Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
二、TARGETS->WebDriverAgentLib的Signing選擇使用我的的證書。
三、TARGETS->WebDriverAgentRunner的Signing選擇使用我的的證書。
四、PROJECT->WebDriverAgent的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
五、TARGETS->WebDriverAgentLib的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
六、TARGETS->WebDriverAgentRunner的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
七、Device選擇已鏈接的測試機
八、點擊build按鈕來測試,按照步驟設置後,可build succeeded~
九、測試機上安裝證書,執行如下命令:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=測試機的udid' test
若是沒有報錯證實安裝成功,同時手機上會安裝一個WebDriverAgent軟件。須要在手機設置->通用->設備管理->信任開發者。以下圖:
Appium Client有Ruby,Python,Java三個版本,可自行選擇本身喜歡的安裝便可,本次只針對Python版安裝:
pip install Appium-Python-Client
以上,接下來能夠定位元素,推薦使用App Inspector,開始iOS自動化之旅吧~~