版權聲明:本文為博主原創(chuàng)文章淆九,歡迎轉(zhuǎn)載统锤,轉(zhuǎn)載請注明作者、原文超鏈接炭庙。
一饲窿、appium配置
1 . AppStore下載Xcode直接安裝即可;
2 .下載Android SDK焕蹄,測試Android App需要逾雄。
下載地址:https://developer.android.com/studio/index.html#downloads
選擇:android-sdk_r24.4.1-macosx.zip(寫本文時的最新版)如圖:
解壓縮到任意位置,比如/usr/local/android-sdk-macosx,
運行/usr/local/android-sdk-macosx/tools/android腻脏,即可啟動Android SDK Manager鸦泳,如圖:
保持默認的選項即可,點擊Install 23 packages…永品。進入到下圖:
Accept License做鹰。然后Install就可以了。這個過程根據(jù)網(wǎng)速不同鼎姐,可能需要10-20分鐘钾麸,耐心等待。
3.設置Android環(huán)境變量:
方法 1:點擊桌面空白位置然后使用快捷鍵shift+cmd+G炕桨,輸入~/.bash_profile喂走,找到.bash_profile文件,打開后在該文件中添加:
export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/usr/local/android-sdk-macosx
終端執(zhí)行 source ~/.bash_profile 使環(huán)境變量生效谋作。
方法 2:終端輸入:
vi .bash_profile
按 i 鍵進入bash_profile文件編輯模式芋肠,完成之后esc鍵退出編輯,:wq結(jié)束遵蚜。
同樣執(zhí)行 source ~/.bash_profile 使環(huán)境變量生效帖池。
至此,為了安裝Appium所需要的Mac平臺已經(jīng)配置完畢了吭净。接下來開始安裝Appium睡汹。
二、Appium安裝
Appium官網(wǎng)下載:https://bitbucket.org/appium/appium.app/downloads/
直接安裝即可寂殉。
appium doctor用來appium的是否成功安裝囚巴,即點擊下圖按鈕:
終端輸出信息像下面這樣全是對號,則表示環(huán)境安裝成功了友扰。
Last login: Tue Nov 1 14:55:59 on ttys002
wldeMacBook-Pro:~ wl$ '/Applications/Appium.app/Contents/Resources/node/bin/node' '/Applications/Appium.app/Contents/Resources/node_modules/appium-doctor/appium-doctor.js'
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ? Xcode is installed at: /Applications/Xcode7.3.1.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.
info AppiumDoctor ? The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ? HOME is set to: /Users/wl
info AppiumDoctor ? ANDROID_HOME is set to: /usr/local/android-sdk-macosx
info AppiumDoctor ? JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
info AppiumDoctor ? adb exists at: /usr/local/android-sdk-macosx/platform-tools/adb
info AppiumDoctor ? android exists at: /usr/local/android-sdk-macosx/tools/android
info AppiumDoctor ? emulator exists at: /usr/local/android-sdk-macosx/tools/emulator
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor
注:Android設置環(huán)境變量遇到的問題:
在.bash_profile文件中配置的環(huán)境變量路徑都沒有問題彤叉,但是使用appium-doctor檢查后一直是:
? ~ '/Applications/Appium.app/Contents/Resources/node/bin/node' '/Applications/Appium.app/Contents/Resources/node_modules/appium-doctor/appium-doctor.js'
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ? Xcode is installed at: /Applications/Xcode7.3.1.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.
info AppiumDoctor ? The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ? HOME is set to: /Users/WL
WARN AppiumDoctor ? ANDROID_HOME is NOT set!
WARN AppiumDoctor ? JAVA_HOME is NOT set!
WARN AppiumDoctor ? adb could not be found because ANDROID_HOME is NOT set!
WARN AppiumDoctor ? android could not be found because ANDROID_HOME is NOT set!
WARN AppiumDoctor ? emulator could not be found because ANDROID_HOME is NOT set!
info AppiumDoctor ### Diagnostic completed, 5 fixes needed. ###
info AppiumDoctor
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor - Manually configure ANDROID_HOME.
WARN AppiumDoctor - Manually configure JAVA_HOME.
WARN AppiumDoctor - Manually configure ANDROID_HOME and run appium-doctor again.
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye, run appium-doctor again when the all the manual fixes have been applied!
info AppiumDoctor
排查原因:
1.打開.bash_profile文件士败,輸入 echo hello from bash_profile!
2.打開Mac自帶的終端Terminal(不是iTerm2)矢炼,發(fā)現(xiàn)并沒有輸出我剛剛在.bash_profile中輸入的那句Hello from bash_profile!,所以可以判定打開終端時并沒有加載.bash_profile文件讀取到ANDROID_PATH和JAVA_PATH唁奢。
解決方法:
1.打開Terminal甚负,終端->偏好設置柬焕,發(fā)現(xiàn)目前的設置如圖所示:
修改之后如下圖即可(即 使用bash shell去載入.bash_profile文件, Linux使用Bash作為默認Shell):
驗證一下审残,再次點擊Appium界面的appium-doctor按鈕,終端顯示如圖:
打印出剛剛在.bash_profile中輸入的Hello from bash_profile!
并且Android環(huán)境配置成功斑举!
上面的這種修改方式并沒有更改此時默認的shell,終端輸入:
echo $SHELL
輸出如下:
/bin/zsh
發(fā)現(xiàn)使用的shell默認還是zsh,這樣在iTerm2中可以繼續(xù)使用zsh.
下面第二種修改方式會更改默認使用的shell:
1.Mac自帶的Terminal的偏好設置不做更改搅轿,還是如下圖:
2 . 除了默認的Bash以外的Shell,查看一下系統(tǒng)上安裝了哪些Shell富玷。系統(tǒng)將安裝的Shell程序列表放在/etc/shells文件中璧坟,終端輸入以下命令行查看該文件獲取Shell列表:
cat /etc/shells
終端輸出:
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
(/bin/zsh即zsh的安裝目錄)
3.修改默認shell為bash
chsh -s /bin/bash
4.點擊appium-doctor檢驗: