? ? appium是移動端的一個開源測試框架靠益,由于跨平臺丧肴、支持多語言等特點,使其在移動端自動化領域不斷地發(fā)展壯大胧后。以mac系統(tǒng)為例芋浮,appium的相關部署介紹如下。
? ? 首先壳快,要檢查環(huán)境纸巷。在命令窗口輸入命令“brew -v”、“npm -v”眶痰,檢查homebrew何暇、npm的安裝情況,這一步是為了方便使用這兩個工具安裝接下來使用到的工具凛驮。若有返回對應版本號裆站,則表示已安裝,若未安裝黔夭,則自行安裝該工具宏胯,當然java jdk請先自行安裝好。
? ?現在正式開始安裝appium本姥。appium需要依賴node.js肩袍,所以需要使用“brew install node"安裝該依賴包。革命的道路總是曲折的婚惫,報錯了,錯誤如下:
/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `': Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)先舷。
? ? 很明顯,當前安裝的node.js要求2.3版本以上的ruby牲芋。于是去升級ruby版本。升級步驟如下:1.查看ruby可升級版本,使用命令”rvm list known“缸浦,結果如下:
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head
......(這里省略其他返回結果)
選擇一個版本進行安裝夕冲,我們這里選擇2.3.4版本裂逐。使用rvm命令安裝:rvm install 2.3.4歹鱼。沒錯卜高,又遇到攔路虎了醉冤,報了一個錯:
......(這里省略一些無關緊要的返回信息)
Installing required packages: autoconf, automake, libtool, pkg-config, coreutils, libyaml, readline, libksba..There were package installation errors, make sure to read the log.-Try `brew tap --repair` and make sure `brew doctor` looks reasonable.Check Homebrew requirements https://github.com/Homebrew/homebrew/wiki/Installation..Error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config coreutils libyaml readline libksba',please read /Users/chenzepeng/.rvm/log/1524469165_ruby-2.3.4/package_install_autoconf_automake_libtool_pkg-config_coreutils_libyaml_readline_libksba.logRequirements installation failed with status:?
1.造成上面錯誤的原因有很多個,百度到幾個原因:brew或其他工具版本過低或未安裝導致篙悯、xcode命令行工具未安裝蚁阳、一些依賴包被墻導致下載失敗等鸽照。這里是因為沒有安裝xcode命令行工具導致的,于是通過終端命令”xcode-select --install“安裝該工具(Ps:如果是使用brew install ruby@2.3.4則會更明顯的提示出錯原因矮燎,例如報如下錯誤:Error: Xcode alone is not sufficient on El Capitan.Install the Command Line Tools:xcode-select --install,直接告訴你要安裝Xcode-select)澜沟。
? ? 安裝完畢后,重新執(zhí)行命令”rvm install 2.3.4“茫虽,ruby升級成功。然后繼續(xù)安裝node.js濒析。node安裝完畢后啥纸,就可以開始安裝appium了。這里提供兩種方式安裝斯棒。
? ? 第一種,命令行安裝荣暮。輸入命令”npm install -g appium“。
? ? 第二種蜈块,下載桌面版appium安裝迷扇。建議到官方網站下載最新版本百揭,網址為”appium.io“蜓席。下載到本地后,和安裝其他程序一樣正常安裝即可(這里建議使用桌面版祈秕,體驗比較好)。
? ? 安裝appium成功后请毛,就可以使用appium-doctor檢查環(huán)境是否部署成功了瞭亮。首先使用”npm install -g appium-doctor“安裝appium-doctor。成功后统翩,執(zhí)行命令”appium-doctor“,若返回結果所有項都檢查通過厂汗,則appium環(huán)境部署完畢。結果如下:
info AppiumDoctor Appium Doctor v.1.4.3info AppiumDoctor?
### Diagnostic starting?
###info AppiumDoctor? ??
The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor? ? Node version is 9.11.1
info AppiumDoctor? ? Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor? ? Xcode Command Line Tools are installed.
info AppiumDoctor? ? DevToolsSecurity is enabled.
info AppiumDoctor? ? The Authorization DB is set up properly.
WARN AppiumDoctor? ? Carthage was NOT found!
info AppiumDoctor? ? HOME is set to: /Users/chenzepeng
info AppiumDoctor? ? ANDROID_HOME is set to: /Users/chenzepeng/sdk/android-sdk-macosx
info AppiumDoctor? ? JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
info AppiumDoctor? ? adb exists at: /Users/chenzepeng/sdk/android-sdk-macosx/platform-tools/adb
info AppiumDoctor? ? android exists at: /Users/chenzepeng/sdk/android-sdk-macosx/tools/android
info AppiumDoctor? ? emulator exists at: /Users/chenzepeng/sdk/android-sdk-macosx/tools/emulator
WARN AppiumDoctor? ? Bin directory for $JAVA_HOME is not set
info AppiumDoctor ### Diagnostic completed, 2 fixes needed.?
###info AppiumDoctor?info AppiumDoctor?
### Manual Fixes Needed?
###info AppiumDoctor
?The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor - Please install Carthage. Visit https://github.com/Carthage/Carthage#installing-carthage for more information.
WARN AppiumDoctor - Add '$JAVA_HOME/bin' to your PATH environment
info AppiumDoctor ###info AppiumDoctor?info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!info AppiumDoctor
?上面信息表明有兩項不通過(Carthage未安裝贾节、java_home未設置)衷畦,根據檢查結果更改后,再次檢查戴差,直到所有項都檢查通過即完成appium環(huán)境部署。