Airtest 生成报告的时候,每个不走都会自动带上截图,也可以自己添加截图,使用 snapshot()方法
对目标设备进行一次截图,并且保存到文件中。
参数:
ST.LOG_DIR
中返回: 截图文件的绝对路径
支持平台: Android, iOS, Windows
示例:
>>> snapshot(msg="index")
>>> # save the screenshot to test.jpg
>>> snapshot(filename="test.png", msg="test")
可以设置截图的画质和大小
>>> # Set the screenshot quality to 30
>>> ST.SNAPSHOT_QUALITY = 30
>>> # Set the screenshot size not to exceed 600*600
>>> # if not set, the default size is the original image size
>>> ST.IMAGE_MAXSIZE = 600
>>> # The quality of the screenshot is 30, and the size does not exceed 600*600
>>> touch((100, 100))
>>> # The quality of the screenshot of this sentence is 90
>>> snapshot(filename="test.png", msg="test", quality=90)
>>> # The quality of the screenshot is 90, and the size does not exceed 1200*1200
>>> snapshot(filename="test2.png", msg="test", quality=90, max_size=1200)
点 app 启动图标,启动后 sleep 5秒,对 app 屏幕截图
查看报告,显示截图
Airtest IDE 自动化测试13 - 报告加截图 snapshot
原文:https://www.cnblogs.com/yoyoketang/p/14840902.html