Airtest框架核心依赖poco脚本,iOS设备运行poco脚本需要安装WebDriverAgent代理(iOS也可以绕过运行WebDriverAgentRunner直接连接设备,后面会讲到),不像安卓可以直接运行。
WebDriverAgent主要用来连接iOS设备捕获当前屏幕,将iOS设备、Airtest IDE建立联系。下面是安装步骤:
一:安装WebDriverAgent:
主要用来连接iOS设备捕获
二:安装homebrew:
打开终端执行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
如果终端报错如下错误
curl:(7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
是因为访问http://raw.githubusercontent.com 不稳定引起的,此时可尝试
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
亲测有效,homebrew安装完要重新配置一下,否则在安装其他软件时会很慢,此时替换下国内镜像源即可,
替换 brew.git:
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替换 homebrew-core.git:
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
homebrew基本用法:
// 查询:
brew search 软件名
// 安装:
brew install 软件名
// 卸载:
brew uninstall 软件名
// 更新 Homebrew:
brew update
// 查看 Homebrew 配置信息:
brew config
三:安装Git:
终端执行:
brew install git
四:安装carthage:
终端执行:
brew install carthage
五:设置代理:
下载https://github.com/facebookarchive/WebDriverAgent,终端执行:
git clone https://github.com/facebookarchive/WebDriverAgent.git
下载好之后,终端执行bootstrap.sh
cd WebDriverAgent
./Scripts/bootstrap.sh
1)打开Xcode配置WebDriverAgentRunner项目的Bundle ID,可以自定义命名(id命名不能重复)
2)导入证书
3)选择Product -> Scheme -> WebDriverAgentRunner,选择Product -> Destination -> 连接的iOS设备名称(这里也可以运行模拟器,如果是模拟器的话,后面配置连接设备地址的url需要改成本地电脑网络地址即可,别忘了带上端口号!!!)
4)运行Product -> Test
5)打开终端安装libimobiledevice并配置端口:
# 安装libimobiledevice
brew install libimobiledevice
# 检测端口
iproxy 8100 8100
六:连接设备:
打开Airtest编译器,找到Devices设备管理处,选择iOS连接设备
输入连接地址:
至此Airtest环境准备工作都完成了,可以尽情做你想做的事情喽!!!