张家界建设网站制作,seo怎么做关键词排名,晚上奖励自己的网站推荐,做网站什么内容吸引人1. 前言
本次更新为Airtest库更新#xff0c;版本提升至1.3.0.1版本#xff0c;主要新增了一些iOS设备相关的装包等接口#xff0c;以及封装了一些tidevice常用接口。更多更新详情#xff0c;详见我们下文的描述。
2. 新增iOS设备接口
1#xff09;iOS安装接口#xf…1. 前言
本次更新为Airtest库更新版本提升至1.3.0.1版本主要新增了一些iOS设备相关的装包等接口以及封装了一些tidevice常用接口。更多更新详情详见我们下文的描述。
2. 新增iOS设备接口
1iOS安装接口install、install_app
对于 本地USB连接的iOS设备 新版本支持装包功能
# 可以直接使用install接口支持通过本地.ipa文件安装APP也支持通过下载链接安装APP
install(rD:\demo\test.ipa)
install(http://www.example.com/test.ipa) # 也可以先获取当前设备用device().install_app的方式装包
dev device()dev.install_app(rD:\demo\test.ipa)
dev.install_app(http://www.example.com/test.ipa) 2iOS卸载接口uninstall、uninstall_app
对于 本地USB连接的iOS设备 新版本支持卸载功能
# 可以直接使用uninstall接口卸载包体
uninstall(com.netease.cloudmusic)# 也可以先获取当前设备用device().uninstall_app的方式卸载包体
dev device()dev.uninstall_app(com.netease.godlike)3列出iOS设备所有APP的接口list_app
对于 本地USB连接的iOS设备 新版本支持列出APP列表的功能
在 list_app(user) 里传入要列出的app类型我们可以得到相应的app列表。 参数可选 user/system/all 分别表示列出用户安装的app/系统app/全部app。 返回值示例[(com.apple.mobilesafari, Safari, 8.0), ...] 。
dev device()#列出并打印全部APP
all_app dev.list_app(all)
print(all_app)#打印系统APP
print(dev.list_app(system))#列出并打印用户安装的APP
user_app dev.list_app(user)
print(user_app)4iOS剪切板功能get_clipboard、set_clipboard
对于iOS设备本地、远程均可新版本支持剪切板功能
#获取剪切板内容
text get_clipboard()
print(text)#设置剪贴板内容
set_clipboard(content)注意当iOS设备为 远程设备 、或者 安装了不止一个wda 时需要指定具体的 wda_bundle_id 才能使用
#获取剪切板内容
text get_clipboard(wda_bundle_idcom.WebDriverAgentRunner.xctrunner)#设置剪贴板内容
set_clipboard(content, wda_bundle_idcom.WebDriverAgentRunner.xctrunner)3. 新增tidevice相关接口
针对本地USB接入的iOS设备Airtest结合tidevice的能力封装了一个 TIDevice 对象提供了几个常用接口如下
devices 列出USB连接的所有设备的 UDID 列表list_app 列出手机上安装的应用列表支持对类型进行筛选包括 user/system/alllist_wda 列出手机上安装的所有WDA的 bundleIDdevice_info 获取手机信息install_app 安装ipa包支持本地路径或URLuninstall_app卸载 bundle_id 对应的包体start_app 启动 bundle_id 对应的包体stop_app 停止 bundle_id 对应的包体ps 获取当前的进程列表ps_wda 获取当前启动中的WDA列表xctest启动WDA
可以参考https://github.com/AirtestProject/Airtest/blob/master/tests/test_tidevice.py 。
代码执行效果示例 from airtest.core.ios.ios import TIDevicedevices TIDevice.devices()print(devices)
[10da21b9091f799891557004e4105ebab3416cb9]udid devices[0] print(TIDevice.list_app(udid))
[ (com.230316modified.WebDriverAgentRunner.xctrunner, wda-Runner, 1.0),] print(TIDevice.list_app(udid, system))
[(com.apple.calculator, Calculator, 1.0.0),] print(TIDevice.list_wda(udid))
[com.test.WebDriverAgentRunner.xctrunner] print(TIDevice.device_info(udid))
{productVersion: 12.4.8, productType: iPhone7,2, modelNumber: MG472, serialNumber: DNPNW6EJG5MN, timeZone: Asia/Shanghai, uniqueDeviceID: 10da21b9091f799891557004e4105ebab3416cb9, marketName: iPhone 6} TIDevice.start_app(udid, com.apple.mobilesafari) TIDevice.stop_app(udid, com.apple.mobilesafari) print(TIDevice.ps(udid))
[ {pid: 215, name: MobileMail, bundle_id: com.apple.mobilemail, display_name: MobileMail}] print(TIDevice.ps_wda(udid))
[com.test.WebDriverAgentRunner.xctrunner]另外TIDevice.xctest 接口的执行示例如下
import threading
wda_bundle_id TIDevice.list_wda(udid)[0]
# 创建一个线程执行xctest
t threading.Thread(targetTIDevice.xctest, args(udid, wda_bundle_id), daemonTrue)
t.start()
time.sleep(5)
ps_wda TIDevice.ps_wda(udid)
print(ps_wda)
time.sleep(5)
# 终止线程
t.join(timeout3)4. 新增错误类型NoDeviceError
如果当前未连接任何设备但是又调用了某些需要连接设备才可以调用的接口时抛出异常 NoDeviceError(No devices added.) 5. using接口的改动
using 接口的作用是支持在脚本中引用另外一个脚本同时还能够让Airtest正确地读取到其他脚本中的图片路径。
假设目录结构如下
demo/foo/bar.airbaz.airmain.py如果我们希望在 main.py 中引用 foo/bar.air 和 baz.air可以将项目根路径设置到 ST.PROJECT_ROOT 或者确保项目根路径是当前工作目录
# main.py
from airtest.core.api import *
ST.PROJECT_ROOT rD:\demo # This line can be ignored if it is the current working directory
using(foo/bar.air)
using(baz.air)如果我们希望在 foo/bar.air 中引用 baz.air 可以这样写
# foo/bar.air
from airtest.core.api import *
using(../baz.air)6. 其它优化与改动
当Airtest脚本引发了 assert 异常时退出码为 20 以便和其他报错区分更新了 Yosemite.apk 修复了一些稳定性问题windows平台新增接口 set_focus 与原先的 set_foreground 功能相同
7. 如何更新
因本次更新仅更新了Airtest库所以同学们目前只能在自己本地python环境中将Airtest更新到最新版本
pip install -U airtest对于使用AirtestIDE的同学可以等我们发布1.2.16版本的IDE或者在旧版本AirtestIDE中设置使用本地python环境然后将本地python环境的Airtest库升级到最新版本即可。 8. 更新常见问题
如同学们在使用新版的Airtest时遇到了一些问题无法解决特别是iOS新增接口相关的问题可以通过此网站向我们的开发者快速提单https://airtest.netease.com/issue_create 。
可以在标题中加入“Airtest1.3.0.1”之类的字眼方便我们快速筛选和排查。