mac下Appium環境配置

1、Appium環境搭建
一、xcode(須要OS X版本支持):
下載對應版本的xcode(支持對應手機系統),解壓,拖入應用程序。
二、安裝appium:
安裝node、brew、nmp、carthage等: http://www.jianshu.com/p/efa9ac4900a6
1)若是有舊版本的appium,須要先卸載舊版本的appium:npm uninstall -g appium
2)下載appium1.6.5正式版: https://github.com/appium/appium/releases/tag/v1.6.5,終端進入文件目錄,命令行安裝:npm install。
      驗證安裝成功:終端輸入「appium -v」,出現版本號表示安裝成功。
  此處有坑:appium-desktop 1.6.4及如下不支持xcode9.0.1,(請注意本身的xcode版本和appium版本,要否則會報錯)
3)與系統進行關聯:npm link
4)安裝appium桌面程序: https://github.com/appium/appium-desktop/releases/tag/v1.2.0,下載zip包,解壓,拖入應用程序。
5)Appium自帶的WebDriverAgent存在bug,改使用FaceBook的WebDriverAgent(WebDriverAgent下載: https://github.com/facebook/WebDriverAgent/):
從git上下載WebDriverAgent,進入/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent 目錄,命令行運行:./Scripts/bootstrap.sh,下載依賴,而後將該文件替換appium應用中的WebDriverAgent(目錄:/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent )
使用xcode打開WebDriverAgent程序,在真機上安裝WebDriverAgent程序,手機上出現WebDriverAgent應用表示安裝成功。(在通用-> 描述文件文件中信任xcode使用的開發者證書)
三、檢測appium環境:
終端輸入:appium-doctor
四、啓動appium桌面程序:
啓動Appium。在運行自動化測試腳本前必定要先運行Appium,啓動測試應用。
1)經過下面的兩種方式啓動appium服務器。(appium啓動會先啓動webdriveragent,啓動以後不要將webdriverAgent關閉,不然再次啓動appium會報錯)
方式一、經過命令行安裝的appium能夠經過終端啓動,終端輸入:appium,看到終端打印出下面日誌,表示服務器啓動成功。
 
方式二、已經安裝了appium桌面程序能夠經過啓動桌面程序來啓動appium服務器。打開程序看到以下頁面:
 
 
直接點擊Start Server便可啓動appium服務器,跟終端命令行啓動打印出的日誌同樣,以下所示:
 
 
上圖三個紅色框分別表示:①查看應用元素(inspector)②保存日誌文件③中止appium服務器。
啓動了appium服務器以後。能夠直接運行自動化。
)配置一些Desired Capabilities信息:
 
 
默認會以127.0.0.1ip和4723端口啓動一個session,若是要啓動多個session,能夠經過修改端口號的方式:點擊Custom Server,服務器ip輸入127.0.0.1,端口輸入一個目前未在使用的端口號就能夠了。
通常須要填寫的參數有platformName(平臺)、platformVersion(平臺版本)、udid(設備的udid,填錯不能啓動應用)、deviceName(設備名稱)、bundleid(應用的bundleid)、automationName(必須填寫XCUITest,不寫默認是UIAutomation的方式,該方式不支持IOS10)。
要鏈接iOS真機,必須打開真機的開發者模式。
而後選中要啓動的已經配置好的信息,點擊Start Session。看到下面的畫面表示啓動成功,能夠查看元素的accessibility_id、xpath、value等和座標。支持錄製腳本。
 
2、安裝及運行過程當中遇到的坑
坑一、
A new session could not be created. Details: Appium's IosDriver does not support xcode version 8.3.3.
Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.
解決方案:
在--capability添加automationName=XCUITest參數
 
坑二、
AssertionError: Message: An unknown server-side error occurred while processing the command.
Original error: Unknown device or simulator UDID: '***'
解決方案:
Appium使用idevice_id(libimobiledevice的一部分)來肯定設備的可用性
brew install libimobiledevice --HEAD
 
坑三、
AssertionError: Message: An unknown server-side error occurred while processing the command. Original error: 
Could not initialize ios-deploy make sure it is installed (npm install -g ios-deploy) and works on your system
解決方案:
安裝ios-deploy
npm install -g ios-deploy
 
坑5:
appium-desktop 1.6.4及如下不支持xcode9.0.1,須要升級appium
 
坑6:
webdriverAgent安裝失敗
解決方案:
從新編譯webdriverAgent,參考地址
 
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=3825bba08e5c10c499ddaf0276bac01983ab7119' test
 
相關文章
相關標籤/搜索