基于 Appium 的 iOS 真機 UI 自動化測試配置 (詳)
導(dǎo)讀:WebDriverAgent 簡介 :https://testerhome.com/topics/4904
一、WebDriverAgent 的安裝和配置
MacOS 上的 Appium 安裝和環(huán)境配置啊研,請參考:https://testerhome.com/topics/13144
-
在真實 iOS 設(shè)備上安裝 WebDriverAgentRunner
必要的軟件:libimobiledevice 纳本、ios-deploy
brew install libimobiledevice --HEAD npm install -g ios-deploy
可知在真機上使用 WebDriverAgent 共用三種配置方式:Basic (automatic) configuration 郁稍、Basic (manual) configuration、Full manual configuration 较坛。
這里使用第三種蹂风,F(xiàn)ull manual configuration <全人為配置的方式>(可使用免費 Apple ID乾翔,無需開發(fā)者賬號)籽腕,具體流程如下:
1. go to => /appium/node_modules/appium-xcuitest-driver/WebDriverAgent 2. mkdir -P /Resources/WebDriverAgent.bundle 3. sh ./Scripts/bootstrap.sh -d 4. open WebDriverAgent.xcodeproj 5. build WebDriverAgent project with sign
這里需要注意第五點??build WebDriverAgent project with sign嗡呼!
-
配置 WebDriverAgentLib 簽名,修改 Bundle Indentifier 為自定義皇耗,與 facebook 不沖突即可南窗。
image
-
配置 WebDriverAgentRunner 簽名,修改 Bundle Indentifier 為自定義
imageimage
-
增加 WDA 依賴 RoutingHTTPServer.freamwork 框架
image
點擊 Xcode 標題欄郎楼,選擇 Product => Scheme => WebDriverAgentRunner
選擇 Rroduct => Test万伤,即可編譯安裝 WebDriverAgentRunner 至 iOS 設(shè)備。
最后在 iOS 設(shè)備上進入設(shè)置APP => 通用 => 設(shè)備管理 => 信任你的 Apple ID 安裝的應(yīng)用
二箭启、元素定位
-
安裝和配置 Macaca app-inspector
# macaca-cli npm install macaca-cli -g # app-inspector npm install app-inspector -g
配置 XCTestWD 簽名
1. go to => app-inspector/node_modules/xctestwd/XCTestWD 2. open XCTestWD.xcodeproj 3. build XCTestWD project with sign
同理 build XCTestWD project with sign 要求在 Xcode 里配置 XCTestWD 項目的簽名壕翩。
image
-
使用 app-inspector
app-inspector -u <udid>
udid 可通過
idevice_id -l
查看。image
使用命令成功會自動打開瀏覽器傅寡,即可獲取界面元素:
本文完~