参考资料
Mac安装Appium_mac电脑安装appium-CSDN博客
安卓测试工具:Appium 环境安装(mac版本)_安卓自动化测试mac环境搭建-CSDN博客
1. 基本环境依赖
1 node.js
2 JDK(Java JDK)
3 Android SDK
4 Appium(主要是安装appium desktop版本)
5 Appium主要依赖
6 Appium-doctor(验证环境是否搭建完成)
2. 安装cnpm
由于npm源在国外,我们使用npm安装库时会比较慢,可以使用taobao的镜像源
npm install -g cnpm --registry=https://registry.npm.taobao.org
检查安装是否成功
cnpm -v
如遇安装cnpm报错
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/appium
npm ERR! dest /usr/local/lib/node_modules/.appium-cfBVovI6
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/appium' -> '/usr/local/lib/node_modules/.appium-cfBVovI6'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/appium' -> '/usr/local/lib/node_modules/.appium-cfBVovI6'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/appium',
npm ERR! dest: '/usr/local/lib/node_modules/.appium-cfBVovI6'
npm ERR! }
解决办法:彻底解决全局安装权限问题_npm err! code eacces npm err! syscall mkdir npm er
cd ~
mkdir .npm-global
npm config set prefix '~/.npm-global'
export PATH="~/.npm-global/bin:$PATH"
再次执行
npm install -g cnpm --registry=https://registry.npm.taobao.org
3. 安装appium无界面版:npm i -g appium@next
4. 安装appium 客户端 (老版)
方法一:官网下载进行安装(不推荐,不翻墙的话,有时候很难下载到),地址:http://appium.io/
方法二:链接: https://pan.baidu.com/s/1sYacv6dwYgYeWN3r_pbzgA 提取码: v464
安装完成后点击Start Server按钮
安装appnium-desktop server端
Releases · appium/appium-desktop · GitHub
5. 安装appium-doctor来确认安装环境是否完成
cnpm install -g appium-doctor
6. 启动appium 在终端执行 appium
如遇Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
https://blog.51cto.com/u_15127509/4222891
查看端口占用情况:lsof -i:4723
杀掉appium进程:ps -ef|grep 'appium'|awk '{print $2}'|xargs kill -9
7. 安装appium驱动uiautomator2
(base) qa@yueyutu:~$ appium driver list
✔ Listing available drivers
- uiautomator2 [not installed]
- xcuitest [not installed]
- mac2 [not installed]
- espresso [not installed]
- safari [not installed]
- gecko [not installed]
- chromium [not installed]
(base) qa@yueyutu:~$appium driver install uiautomator2
8. 由于还没安装xcode,所以会有Xcode相关的报错,暂时忽略