1.macOS相關(guān)庫安裝
- libimobiledevice
> brew install libimobiledevice
使用本機(jī)與蘋果iOS設(shè)備的服務(wù)進(jìn)行通信的庫。
- ideviceinstaller
brew install ideviceinstaller
獲取設(shè)備udid、安裝app、卸載app、獲取bundleid
- carthage
> brew install carthage
第三方庫管理工具。
- ios-deploy
> brew install ios-deploy
ios-deploy 不依賴于XCODE,進(jìn)行安裝和調(diào)試IOS應(yīng)用程序。
- node & npm
> brew install node
> brew install npm
- appium-doctor
npm install -g appium-doctor
- 驗(yàn)證appium環(huán)境
> appium-doctor
info AppiumDoctor Appium Doctor v.1.11.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ? The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ? Node version is 10.15.1
info AppiumDoctor ? Xcode is installed at: /Applications/Xcode-beta.app/Contents/Developer
info AppiumDoctor ? Xcode Command Line Tools are installed in: /Applications/Xcode-beta.app/Contents/Developer
info AppiumDoctor ? DevToolsSecurity is enabled.
info AppiumDoctor ? The Authorization DB is set up properly.
info AppiumDoctor ? Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.33.0
info AppiumDoctor ? HOME is set to: /Users/tech
...
2.XCode
Xcode 是iOS開發(fā)環(huán)境,可以到app store 下載安裝。
Xcode 的安裝需要macOS升級(jí)到最新的版本,如果你的系統(tǒng)不是最新版本需要升級(jí)。
WebDriverAgent
在模擬器中運(yùn)行的用于iOS的WebDriver服務(wù)器。
GitHub - appium/WebDriverAgent: A WebDriver server for iOS and tvOS
該項(xiàng)目由facebook開發(fā),appium拉了個(gè)分支來維護(hù),更新上超過了facebook,所以我們用appium的分支。
-
通過git clone 將項(xiàng)目克隆下來。
-
進(jìn)入項(xiàng)目目錄執(zhí)行shell腳本:
../WebDriverAgent> ./Scripts/bootstrap.sh
- 通過xcode導(dǎo)入WebDriverAgent 項(xiàng)目
- 找到build Settings ---> packaging---> Product Bundle Identifier 選項(xiàng)。將值修改為唯一識(shí)別的字符串。
- Build Phases ---> Copy frameworks ---> 檢查框架。
- RoutingHTTPServer.framework
- YYCache.framework
如果沒有這兩個(gè)框架,點(diǎn)擊下方加號(hào)+添加。
3.iPhone
準(zhǔn)備一臺(tái)iPhone手機(jī),通過數(shù)據(jù)線與PC進(jìn)行連接。
1.選擇連接的手機(jī)
2.菜單欄:product --> Scheme --> WebDriverAgentRunner
3.菜單欄:Product---> Test
4.在iPhone手機(jī)上打開設(shè)置:通用--> 描述文件與設(shè)備管理--> 開發(fā)者App ,設(shè)置Apple Development xxxxx 在此iPhone上受信任。
5.檢查日志是否有錯(cuò)誤。
4.iproxy
安裝 usbmuxd,他自帶了iproxy小工具,iproxy將設(shè)備上的端口映射到電腦上的某個(gè)端口。
> brew install usbmuxd
> iproxy 8100 8100
http://localhost:8100/status
5.開始測(cè)試
終于可以開始測(cè)試了,你有幾種選擇。
-
appium
GitHub - appium/python-client: Python language bindings for Appium -
Openatx
GitHub - openatx/facebook-wda: Facebook WebDriverAgent Python Client Library (not official)
我選 openatx/facebook-wda,因?yàn)樗雍?jiǎn)單。
安裝:
pip3 install -U facebook-wda
測(cè)試腳本:
import wda
c = wda.Client('http://localhost:8100')
print(c.status())
結(jié)果:文章來源:http://www.zghlxwxcb.cn/news/detail-496255.html
{'message': 'WebDriverAgent is ready to accept commands', 'state': 'success', 'os': {'name': 'iOS', 'version': '13.4', 'sdkVersion': '13.4'}, 'ios': {'simulatorVersion': '13.4', 'ip': '192.168.1.8'}, 'ready': True, 'build': {'time': 'Mar 28 2020 23:01:36', 'productBundleIdentifier': 'com.facebook.WebDriverAgentRunner'}, 'sessionId': 'F951380E-7219-4EA9-84FC-CC8BE78A12F8'}
好了,可以開始你的iOS自動(dòng)化測(cè)試了。文章來源地址http://www.zghlxwxcb.cn/news/detail-496255.html
到了這里,關(guān)于iOS自動(dòng)化環(huán)境搭建(超詳細(xì))的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!