Mac下安装及配置Appium环境
我是小白,自己研究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)