python-自动化Airtest-2代码篇 Airtest包
- 一: connect_device 代码
- 1> auto_setup
- 2> Template
- 3> other airtest.core.api
- 1. init_device
- 2. device&connect_device&set_current
- 二级目录
- 三级目录
更完备的 airtest.core.api
https://airtest.readthedocs.io/en/latest/all_module/airtest.core.api.html
auto_setup(__file__, logdir=True, devices=["platform://host:host/uuid?cap_method=value&&ori_method=value",])
platform: Android/iOS/Windows…
host: Android平台是adb host,iOS下是iproxy host,其他平台请留空
port: Android下是adb port,iOS下填写iproxy port,其他平台请留空
uuid: 目标设备的uuid,例如Android下是序列号,windows下是窗口句柄,iOS是uuid
param: 设备初始化的配置字段,例如cap_method/ori_method/…
value: 设备初始化字段的值。
把图片转为代码
Template(r"tpl1532588127987.png", record_pos=(0.779, 0.382), resolution=(407, 264), threshold=0.6, target_pos=5, rgb=False)
参数分别为:截取的图片名, record_pos记录坐标, resolution 分辨率,threshold阈值,target_pos图像点击位置
截取的图片名:可添绝对路径、相对路径
record_pos:记录坐标
resolution :分辨率
threshold:浮点型
target_pos:图像点击位置,向上节IDE介绍1-9 个位置;默认都为5
如果还没有初始化设备,则设置为当前设备
init_device(platform='Android', uuid=None, **kwargs)
参数:
platform :平台– Android, IOS or Windows
uuid :设备号
kwargs :可选的平台其他特定关键字参数
例如:
init_device(platform=“Android”,uuid=“SJE5T17B17”, cap_method=“JAVACAP”)



