Airtest搭建IOS自动化环境

 

概述:

Airtest支持iOS自动化测试,在Mac上为iOS手机部署iOS-Tagent之后,就可以使用AirtestIDE连接设备,像连接安卓设备一样,实时投影、控制手机。iOS测试不仅限于真机测试,iOS模拟器也可以进行

 

 

相关环境:

1.xcode( ≥ 9.3)

2.python环境(≥3.5 <3.9)

3.iOS手机( ≥ 9.3系统版本)

4.pycharm

5.ideviceinstaller

6.airtestIDE

7. iOS-Tagent 

备注: 1.在 9.3≤iOS≤10时,由于基于旧版xcode SDK,建议使用Xcode 版本≤10.1来启动iOS-Tagent,否则会出现手机截屏不全的问题。

2.免费个人版开发者账号的证书有效期为7天(可使用个人付费版账号、企业号、或者证书)

 

 

部署流程

  1. 在Mac下载 iOS-Tagent ,使用 Xcode 启动 Test, 具体启动过程可参考 https://github.com/AirtestProject/iOS-Tagent 。当Xcode的log窗口输出下图信息的时候,就意味着部署成功了。

  2. 启动代理,在命令行下执行iproxy 8100 8100运行代理后,可以在浏览器打开 http://127.0.0.1:8100/inspector ,查看iOS设备是否能成功连接。

iproxy是usbmuxd附带的一个小工具,它的作用是将设备的某个端口映射到电脑的某个端口。mac下可以通过brew安装 brew install usbmuxd

iproxy 8100 8100 意思就是将手机的8100端口,映射到电脑的8100端口上。这样我们就能通过访问电脑的8100端口来访问到手机了。

  1. 在 AirtestIDE 的设备窗口,输入地址:http://127.0.0.1:8100 或 http://x.x.x.x(MAC IP):8100

image

点击Connect按钮即可连接iOS设备,如图:

image

 

到这里设备就可以连接上airtestIDE了;

 

备注:

1.需要一直保持 iOS-Tagent的Test在运行状态(在菜单栏 product -> Test)

2.iproxy在运行状态中

3.有时候WebDriverAgent未响应,或者需要通过自动化执行时,在xcode明显不能满足需要(需要命令shell)

#!/bin/bash
# 解锁keychain,以便可以正常的签名应用,
PASSWORD="123456"
security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain

# 获取设备的UDID
UDID=$(idevice_id -l | head -n1)

# 运行测试
xcodebuild -project /Users/root1/Desktop/iOS-Tagent/WebDriverAgent.xcodeproj  -scheme WebDriverAgentRunner -destination "id=$UDID" test

 

 

 

 相关文档:

https://github.com/AirtestProject/iOS-Tagent/blob/master/Introduction/README_zh.md .......................中文篇部署 iOS-Tagent

https://www.jianshu.com/p/548d23303498   .................airtest导入iOS-tagent遇到的坑  

https://www.zhihu.com/question/298295121 ................xcode可以通过开发者账号或证书,把项目装到手机

https://blog.csdn.net/AirtestProject/article/details/103489723 ................如何在iOS手机上进行自动化测试

https://airtest.doc.io.netease.com/tutorial/6_IOS_automated_testing/      ..............如何在iOS手机上进行自动化测试

https://testerhome.com/topics/7220 .................iOS 真机如何安装 WebDriverAgent

https://blog.csdn.net/hsh881025/article/details/103268225  .....................iOS 自动化测试初探

https://blog.csdn.net/qq_27339239/article/details/103695206 ....................iOS 自动化测试 AirTest+wdaproxy来远程访问

 

posted on 2021-01-12 11:10  chen_2987  阅读(1666)  评论(0编辑  收藏  举报

导航