MAC 系统下UI-Appium自动化测试

前言

入职做软件测试近一年时间,工作内容90%的手工测试,每天点点点。为了提升自己,开始自学UI自动化测试,以下内容都是借鉴网上各大博主的经验,做一个学习汇总,为自己和初学测试的同行提供方便。

环境搭建要求

xcode9.0以上
python3环境,最好安装pycharm
拥有Apple ID 和开发者账号

appium在mac上面的环境配置

参考博客:https://www.jianshu.com/p/505525e2bb01
1.安装Homebrew:
国内镜像(推荐使用中科大):
/bin/zsh -c “ ( c u r l − f s S L h t t p s : / / g i t e e . c o m / c u n k a i / H o m e b r e w C N / r a w / m a s t e r / H o m e b r e w . s h ) " 国 外 镜 像 ( 没 有 成 功 过 ) : / u s r / b i n / r u b y − e " (curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 国外镜像(没有成功过): /usr/bin/ruby -e " (curlfsSLhttps://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"/usr/bin/rubye"(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
2.安装libimobiledevice
brew install libimobiledevice
3.安装ideviceinstaller(真机安装相关)
brew install ideviceinstaller
4.安装carthage
brew install carthage
5.安装node
官方下载安装:https://nodejs.org/en/download/
brew安装:brew install node
node -v:显示node安装版本
6.安装cnpm
npm install -g cnpm
报错可能是因为权限问题,终端运行sudo chown $(whoami):admin /usr/local/lib/node_modules/,重新安装
7.安装iOS-deploy
cnpm install -g ios-deploy
8.安装xcpretty
gem install xcpretty

9.然后开始安装appium:
官方下载安装:https://github.com/appium/appium-desktop/releases
终端安装:npm install -g appium
终端运行:appium --version,查看Appium 版本号
10.安装appium doctor:
npm install -g appium-doctor

11.安装wd和webpack
npm install -g wd
npm i -g webpack

开始配置文件

1.重装appium-xcuitest-driver依赖
终端(先卸载再安装):
cd /usr/local/lib/node_modules/appium/node_modules/(appium-xcuitest-driver的安装路径)
npm uninstall appium-xcuitest-driver
终端安装:npm install appium-xcuitest-driver;官方下载:https://github.com/appium/appium-xcuitest-driver

2.配置WebDriverAgent
直接配置一般都有问题,所以也要重新安装:
cd ~
git clone https://github.com/facebook/WebDriverAgent.git
cd WebDriverAgent
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh
终断下载失败可直接官方下载,手动删除原有的WebDriverAgen,将下载的包拷贝进去
链接: https:https://github.com/appium/WebDriverAgent
3.编译WebDriverAgent
进入目标文件夹,打开WebDriverAgent.xcodeproj项目(已登陆apple ID账号),做如下配置,然后运行
在这里插入图片描述
选择Product–Scheme–WebADriverAgentRunner,点击build进行编译

4.建立服务(手机和MAC在同一网段下),关闭Xcode,进入WebDriverAgent文件夹
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=真机的udid’ test
备注:真机的udid可以在Xcode 获得:点击真机/模拟机,点击Add Additional Simulators,udid为对应机型的identifier
这个时候,真机/模拟机多了一个WebDriverAgentRunner 的APP,表示运行成功

验证appium安装情况

终端运行:appium-doctor --ios

一般情况下,运行appium-doctor --ios会有以下报错,附上解决方法(在网上都搜得到)
1.opencv4nodejs cannot be found.
下载cmake:https://cmake.org/download/
终端运行:sudo “/Applications/CMake.app/Contents/bin/cmake-gui” --install
npm install opencv4nodej

2.ffmpeg cannot be found
brew install ffmpeg

3.mjpeg-consumer cannot be found.
npm i -g mjpeg-consumer

4.set-simulator-location is not installed
brew install lyft/formulae/set-simulator-location

5.idb and idb_companion are not installed
brew tap facebook/fb
brew install idb-companion
pip / pip3.9 install fb-idb

6.applesimutils cannot be found
命令行运行:brew tap wix/brew
brew install applesimutil

安装后再次运行appium-doctor --ios,没有错误则代表安装成功

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值