我是小白,自己研究appium好幾周了。
一開始按照同事這篇文章設置Mac下的環境,http://www.cnblogs.com/tangdongchu/p/4432808.html
因為當時在命令行端沒能用npm install安裝成功,而只是安裝了appium的dmg程序,平時用appium.app端也夠了。但是后續因為需求http://testerhome.com/topics/2616,發現得用命令行調用appium,所以今天再努力一把,用命令行把appium安裝成功。
今天參考了這幾篇文章的步驟安裝appium
http://testerhome.com/topics/1322
http://testerhome.com/topics/315
首先,官方網站上給出的安裝的教程,頗為簡單:
> brew install node # get node.js > npm install -g appium # get appium > npm install wd # get appium client > appium & # start appium > node your-appium-test.js
但,只是看着簡單而已,自己搭建的過程中可能會遇到各種問題
brew install node 想要生效首先必須先安裝homebrew才行,所以第一步應當是檢查自己是否已經安裝homebrew
在終端中輸入brew -v 如果出現版本信息則說明已經安裝
➜ ~ brew -v Homebrew 0.9.5
在終端輸入brew install node 命令安裝node.js 安裝完成后在終端輸入node -v命令檢查是否安裝成功,出現版本信息說明安裝成功
➜ ~ node -v v0.10.35
在終端輸入npm uninstall appium -g,因為被牆,下不下來,即使連接VPN也各種下不下來~
使用其他人推薦的這個鏡像,還是下不下來,花了好長時間,還是不成功,真的好郁悶
npm --registry http://registry.cnpmjs.org install -g appium
后來,找到這篇文章http://testerhome.com/topics/1827
推薦taobao的npm鏡像,下載速度較快,牆裂推薦使用!
npm --registry http://registry.npm.taobao.org install -g appium
npm 安裝好 Appium 好之后,可以運行下 appium-doctor,檢查自己的各種環境變量是否配置成功
➜ ~ appium-doctor
Running iOS Checks
✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer
✔ Xcode Command Line Tools are installed.
✔ DevToolsSecurity is enabled.
✔ The Authorization DB is set up properly. ✔ Node binary found at /usr/local/bin/node ✔ iOS Checks were successful. Running Android Checks ✔ ANDROID_HOME is set to "/Applications/adt-bundle-mac-x86_64-20131030/sdk" ✔ JAVA_HOME is set to "/System/Library/Frameworks/JavaVM.framework/Home." ✔ ADB exists at /Applications/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb ✔ Android exists at /Applications/adt-bundle-mac-x86_64-20131030/sdk/tools/android ✔ Emulator exists at /Applications/adt-bundle-mac-x86_64-20131030/sdk/tools/emulator ✔ Android Checks were successful.
npm install wd 這個也是下載不了,目前不知道是什么東東,不影響就先不管了
在終端輸入 appium& 即可啟動appium,在這里多說一句,直接輸入 appium 也可以啟動appium,只是加個&可以顯示appium的pid,而不加則不會顯示
➜ ~ appium& [2] 3679 ➜ ~ warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! info: Welcome to Appium v1.4.3 (REV a357c7fa73222315dd85c3d2dd8334767cca1b0d) info: Appium REST http interface listener started on 0.0.0.0:4723 info: Console LogLevel: debug
命令行啟動appium之后,如果關閉終端,隔一會你要再運行,會提示error
➜ ~ appium warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! error: Couldn't start Appium REST http interface listener. Requested port is already in use. Please make sure there's no other instance of Appium running already.
因為端口被node占用呢,可以用如下退出node
➜ ~ pkill node [2] 3679 exit 143 appium
也可以用之前自己的笨辦法
知道可以查詢4723端口找到PID,然后kill -9 PID
mac&linux下查看端口被哪個進程占用
mac : lsof -i:8080
linux : neststat -anltp | grep 8080
➜ ~ lsof -i:4723 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 3679 XXXXX 12u IPv4 0xaecf7b4424b87de7 0t0 TCP *:4723 (LISTEN)
未完待續,歡迎拍磚。。。