mac 配置appium環(huán)境

? ? appium是移動(dòng)端的一個(gè)開源測(cè)試框架,由于跨平臺(tái)、支持多語言等特點(diǎn),使其在移動(dòng)端自動(dòng)化領(lǐng)域不斷地發(fā)展壯大。以mac系統(tǒng)為例,appium的相關(guān)部署介紹如下。

? ? 首先,要檢查環(huán)境。在命令窗口輸入命令“brew -v”、“npm -v”,檢查homebrew、npm的安裝情況,這一步是為了方便使用這兩個(gè)工具安裝接下來使用到的工具。若有返回對(duì)應(yīng)版本號(hào),則表示已安裝,若未安裝,則自行安裝該工具,當(dāng)然java jdk請(qǐng)先自行安裝好。

? ?現(xiàn)在正式開始安裝appium。appium需要依賴node.js,所以需要使用“brew install node"安裝該依賴包。革命的道路總是曲折的,報(bào)錯(cuò)了,錯(cuò)誤如下:

/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `': Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)。

? ? 很明顯,當(dāng)前安裝的node.js要求2.3版本以上的ruby。于是去升級(jí)ruby版本。升級(jí)步驟如下:1.查看ruby可升級(jí)版本,使用命令”rvm list known“,結(jié)果如下:

[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

......(這里省略其他返回結(jié)果)

選擇一個(gè)版本進(jìn)行安裝,我們這里選擇2.3.4版本。使用rvm命令安裝:rvm install 2.3.4。沒錯(cuò),又遇到攔路虎了,報(bào)了一個(gè)錯(cuò):

......(這里省略一些無關(guān)緊要的返回信息)

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.造成上面錯(cuò)誤的原因有很多個(gè),百度到幾個(gè)原因:brew或其他工具版本過低或未安裝導(dǎo)致、xcode命令行工具未安裝、一些依賴包被墻導(dǎo)致下載失敗等。這里是因?yàn)闆]有安裝xcode命令行工具導(dǎo)致的,于是通過終端命令”xcode-select --install“安裝該工具(Ps:如果是使用brew install ruby@2.3.4則會(huì)更明顯的提示出錯(cuò)原因,例如報(bào)如下錯(cuò)誤: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升級(jí)成功。然后繼續(xù)安裝node.js。node安裝完畢后,就可以開始安裝appium了。這里提供兩種方式安裝。

? ? 第一種,命令行安裝。輸入命令”npm install -g appium“。

? ? 第二種,下載桌面版appium安裝。建議到官方網(wǎng)站下載最新版本,網(wǎng)址為”appium.io“。下載到本地后,和安裝其他程序一樣正常安裝即可(這里建議使用桌面版,體驗(yàn)比較好)。

? ? 安裝appium成功后,就可以使用appium-doctor檢查環(huán)境是否部署成功了。首先使用”npm install -g appium-doctor“安裝appium-doctor。成功后,執(zhí)行命令”appium-doctor“,若返回結(jié)果所有項(xiàng)都檢查通過,則appium環(huán)境部署完畢。結(jié)果如下:

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

?上面信息表明有兩項(xiàng)不通過(Carthage未安裝、java_home未設(shè)置),根據(jù)檢查結(jié)果更改后,再次檢查,直到所有項(xiàng)都檢查通過即完成appium環(huán)境部署。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容