概述:
tidevice 是阿里的内部的一个小组用来做 iOS 自动化用的工具。最近终于开源了出来,类似android下的adb。
价值:
不依赖 xcode 启动 WebDriverAgent完成设备连接,因为不依赖 Xcodebuild,所以就算你只有 Windows 或者 Linux 也能跑起来 iOS 自动化。
作用:
- 截图
- App安装(支持远程安装),启动,停止,查看
- 启动 WebDriverAgent
- 性能采集(类似 PerfDog)不过这块暂时只有 API 可以用。
- 功能还在不停的扩展中
命令:
tidevice list #查看设备
tidevice screenshot screenshot.jpg #截图
tidevice launch com.apple.Preferences #启动程序
tidevice kill com.apple.Preferences .....停止程序
tidevice applist #查看第三方包名
tidevice -u $UDID xctest -B $BUNDLE_ID #运行WebDriverAgent
tidevice reboot #重启设备
tidevice install https://.....ipa #远程安装
tidevice info #查看设备信息
tidevice -u 设备uid uninstall 包名 .........卸载应用
#多台手机时可指定uid
tidevice -u 设备uid install C:\Users\Administrator\Desktop\test.ipa #指定设备安装
tidevice详细:https://testerhome.com/topics/27758
部署步骤:
1.难点:如何安装WebDriverAgent到手机
需要下载WebDriverAgent项目编译到手机
https://github.com/AirtestProject/iOS-Tagent/blob/master/Introduction/README_zh.md
https://www.cnblogs.com/chen-xia/p/14266014.html
备注:
- 部署iOS测试平台需要苹果开发者证书,现在使用个人Apple ID登陆即可,不需要另外注册付费开发者账号
- 个人版的免费证书,每隔7天左右,要手动更新开发者证书;
- 需要手动的在iPhone中选择信任证书,通用->设备管理->选择信任;
- 最多支持3台设备;
建议:使用公司的企业账号或个人收费账号测试(企业账号可以绑定100台也不需要更新证书),不然很头疼
2.启动WebDriverAgent
tidevice -B $BUNDLE_ID ................通过包名启动WebDriverAgent(单台)
tidevice -u 设备id xctest -B $BUNDLE_ID ............................通过包名启动WebDriverAgent(指定一台)
3.检查设备代理状态(xx表示手机ip)
http://xx.xx.xx.xx:8100/status
4.使用airtest
输入 http://xx.xx.xx.xx:8100/ 点击connet即可连接
##——————————————————————————————————————————————————————————————————————————————————
使用记录:
#!/usr/bin/env python # encoding: utf-8 __author__ = "晨晨" import os #________________________________________tidevice基础封装______________________________________________ class Package_name(object): def __init__(self,device_id,name_list=None): self.device_id=device_id self.name_list=name_list def __call__(self, *args, **kwargs): '''列出设备的三方包名列表''' bb=os.popen('tidevice -u '+self.device_id+' applist').readlines() self.name_list=[ i[:i.find(' '):] for i in bb] return self.name_list def is_no_package3_name(self,packeage_name): '''判断手机是否安装了xx包名''' return True if packeage_name in self.name_list else False def device_info(self): '''获取设备信息_dict格式''' bb=os.popen('tidevice -u '+self.device_id+' info').readlines() self.name_list=([''.join([i for i in price.replace(" ",'').split('\n')]) for price in bb]) self.name_list.pop() json_a={} for i in self.name_list: aa=((i[:i.find(':'):])) bb=(i[i.find(':')+1:].lstrip()) json_a[aa] = bb return json_a if __name__=='__main__': test=Package_name('9592617d97b1d558ad4ced4a31cd0442762ffc05') print('以列表方式列出包名',test()) print('判断设备是否安装xx包',test.is_no_package3_name('com.tencent.xin')) print('设备基础信息:',test.device_info())
相关连接:
https://testerhome.com/articles/29124 .............................................tidevice搭建airtest环境
https://mp.weixin.qq.com/s/xgDnZdMdy5E5af-54ZMXow ..................tidevice相关用法