標籤:
最近在公司,讓做ios的自動化測試,因為以前做過android的自動化測試,用的也是appium,覺得沒什麼,結果一開始在搭建環境就遇到了很多的問題,現在將我遇到的問題,以及解決方案,給大家分享出來。(ps:吐槽一下testhome,發了兩個文章一個提問帖一個心得分享帖,全都給拉到違規區了,問題也沒有人給看)
進入正題,說一下我的環境:
xcode 7.1.1
simulator 9.1
appium 1.4.13
iphone 5s ios9.1
首先說一下,appium 在ios版本選擇這一塊最高版本到了8.4,可能大家會有疑問,我是9.1沒有選項怎麼辦啊。
這個問題提很好解決,大家仔細看看,在設定中那個文字框是可以手動輸入,可以鍵盤輸入的啊,輸入之後記得勾選 下面設定 IOS Setting->advanceed ->Use Native Instruments Library,或者在Developer Settings 勾選enable、Custom Server Flags 並在加入 --native-instruments-lib 請參考:https://discuss.appium.io/t/has-anyone-been-able-to-use-ios-simulator-9-1-with-appium-1-4-13/6887/8
可能大家常見到的問題是這個,發現在啟動inspector後,包也裝到simulator 可是應用已一啟動就閃退,這個問題是因為iOS 的不跨平台,編譯時間必須指定運行在 arm 還是 x86 上。具體在打包時的區別是使用的 sdk 不同。解決這個問題就是直接使用xcode將包安裝在手機虛擬機器上,然後在啟動inspector就可以了。(這裡我有個問題,但我選擇使用bundleID啟動時,提示我找不到包。而使用app path 發現包已經安裝,就不會再次從新安裝,會直接啟動已經安裝的包)
在使用虛擬手機測試的過程中,在使用sendkeys調起IME的時候,可能會報錯:‘An error occurred while executing user supplied JavaScript 這個問題我只有在虛擬手機上遇到過,真機測試時沒有遇到過這種情況。可能是不能調起IME造成的。
下面說一下使用真機啟動inspector時,遇到的問題,真機啟動遇到問題,先貼個log
info: [debug] [INST STDERR] 2015-12-11 17:54:01.261 instruments[10308:11044258] WebKit Threading Violation - initial use of WebKit from a secondary thread.
info: [debug] [INST STDERR] 2015-12-11 17:54:07.289 instruments[10308:11044422] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 3.) : Failed to launch process with bundle identifier ‘com.zipingfang.1‘
info: [debug] [INST STDERR] 2015-12-11 17:54:07.289 instruments[10308:11044241] Attempting to change event horizon while disengage
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall iOS Simulator
沒錯就是 Instruments crashed 這個問題直到今天我才解決了,使用真機進行ios測試要注意以下幾點:
參考:https://discuss.appium.io/t/ios-instruments-crashed-on-startup/1191/14
1.要有開發人員帳號
2.裝置已經被添加至開發人員裝置
3.使用xcode debug 安裝應用至手機
4.描述檔案中 信任此應用的認證
5.在手機設定 -開發人員中 勾選 使用UI Automation.
會繼續更新,如果不對歡迎指正
使用appium進行ios測試,啟動inspector時遇到的問題(一)