Appium 是一個自動化測試開源工具,支持 iOS 平臺和 Android 平臺上的原生應用,web 應用和混合應用。
本次環境配置相關:
macOS:10.13.4
Appium-desktop:1.6.1
Xcode:9.3.1
一、環境配置
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
進入官網,下載Appium-1.6.1.dmg,安裝即可。
當然你可以使用命令:npm install -g appium來安裝appium,但是後面就會各種報錯!!(別問我是怎麼知道的,我搞了2天。)
$ npm install -g appium-doctor
10、使用appium-doctor 檢查Appium iOS環境環境
appium-doctor --ios
info AppiumDoctor Appium Doctor v.1.4.3info AppiumDoctor ### Diagnostic starting ###info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/nodeinfo AppiumDoctor ✔ Node version is 10.1.0info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developerinfo 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/carthageinfo AppiumDoctor ✔ HOME is set to: /Users/wangjuaninfo AppiumDoctor ### Diagnostic completed, no fix needed. ###info AppiumDoctorinfo 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目錄下執行以下命令
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh
3、編譯WebDriverAgent.xcodeproj
Xcode打開當前目錄下的WebDriverAgent.xcodeproj文件
WebDriverAgent.xcodeproj.png
1、TARGETS->WebDriverAgentLib的Bundle Identifier更改為自己命名的Identifier。(所有Identifier注意保持一致!!)
2、TARGETS->WebDriverAgentLib的Signing選擇使用個人的證書。
3、TARGETS->WebDriverAgentRunner的Signing選擇使用個人的證書。
4、PROJECT->WebDriverAgent的Product Bundle Identifier更改為自己命名的Identifier。(所有Identifier注意保持一致!!)
5、TARGETS->WebDriverAgentLib的Product Bundle Identifier更改為自己命名的Identifier。(所有Identifier注意保持一致!!)
6、TARGETS->WebDriverAgentRunner的Product Bundle Identifier更改為自己命名的Identifier。(所有Identifier注意保持一致!!)
7、Device選擇已連接的測試機
8、點擊build按鈕來測試,按照步驟設置後,可build succeeded~
9、測試機上安裝證書,執行以下命令:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=測試機的udid' test
如果沒有報錯證明安裝成功,同時手機上會安裝一個WebDriverAgent軟件。需要在手機設置->通用->設備管理->信任開發者。如下圖:
三、Appium Client端
Appium Client有Ruby,Python,Java三個版本,可自行選擇自己喜歡的安裝即可,本次只針對Python版安裝:
pip install Appium-Python-Client
程序爬蟲抓取有用資源共享給大家
關注後,私信回覆【資料包】獲取如下內容,
閱讀更多 馬蟻蛋 的文章