IOS自动化测试之AirTest

系统环境:
macOS Catalina 10.15.7
Xcode 12.4(12D4e)
iPhone11
IOS 14

软件环境:
Carthage
brew

安装 minicap
https://testerhome.com/topics/10456
17年那些做测试的人都是没问题的,后来出现了一个19年的帖子关于设备未找到的,怀疑是设备版本问题,翻了一下issue,找到解决方案
https://github.com/openstf/ios-minicap/issues/53

简单来说就是把你iPhone的UDID写死上去。。。

获取UDID的方法:
链接数据线,打开访达,左侧导航栏「位置」中会出现你的设备,进去后点击你的设备信息(设备名称下面的一条东西,显示你的设备号、存储空间、电量的那个,没错,那东西可以点,还特么可以右击复制。。。)

复制出来后修改run.sh,将UDID注释,把自己的UDID粘贴过去
# UDID=$(system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/1/p')
UDID=YOUR IPHONE UDID

剩下的按照文章来,进行稳稳的。


安装WebDriverAgent(文章https://testerhome.com/topics/7220)

安装之后没有bootstrap.sh文件,下面评论104楼有一个解决方案(zuinjly #104)
git reset --hard 1eb3280d89e3510845efb5d1f398001313c2615b
将代码回滚到inspector版本

之前Xcode编译报错,稀里糊涂的装了Carthage,所以也就都解决了(安装方式百度一下吧,我忘了)


如果你遇到了下面这个报错,仔细看下内部侧面导航栏的targer选项,你选择的team是不是WebDriverAgentRunner的。。。。我是没仔细看文档,卡了个小坑
Showing Recent Messages
Signing for "WebDriverAgentRunner" requires a development team. Select a development team in the Signing & Capabilities editor.

需要注意的一点是,在Signing & Capabilities界面要勾选All,否则依旧会报相同的错误(在高版本Xcode的环境被划分的更细致了)

另外一个报错
Building for iOS, but the embedded framework 'CocoaAsyncSocket.framework' was built for iOS + iOS Simulator.

这个有一定可能是我不停重复构建导致的问题,一气之下把项目删了重新拉下来,报错消失(我确定有一种删除项目依赖的方式,但是我不知道方法,所以就把项目删咯)。


接下来回到Airtest IDE上,基础工作做了一半,接下来还有四个小时需要踩坑
https://airtest.doc.io.netease.com/IDEdocs/device_connection/4_ios_connection/

接下来是一个通用问题。。
Building for iOS, but the embedded framework 'xxxx' was built for iOS + iOS Simulator.

解决方案
https://stackoverflow.com/questions/65303304/xcode-12-3-building-for-ios-simulator-but-the-linked-and-embedded-framework-wa

Another workaround is to set BuildSettings ->"Validate Workspace" to Yes. It will still show a warning, but will build the project.

点击
WebDriverAgent -> 内部侧边栏 -> PROJECT -> WebDriverAgent -> Build Settings -> All -> Validate Workspace -> yes

也是搞死我。。

最后一步是iproxy

看着文档弄吧……WDA

优先安装WDA
https://testerhome.com/topics/10463

WDA编译完手机里应该有一个开发的图标,然后到设置里把开发权限开起来;
之后iproxy跑起来,就用AirTest默认的8100就好惹...

然后就是写脚本了(没记错的话),python的代码,很是简单,咳。。。


可以晚些更新嘛QAQ
不知道为什么之前明明已经都弄好了之后就没补文档惹Orz

原文地址:https://www.cnblogs.com/Arunoido/p/14824257.html