前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Airtest IDE 自动化测试13 - 报告加截图 snapshot

Airtest IDE 自动化测试13 - 报告加截图 snapshot

作者头像
上海-悠悠
发布2021-06-25 00:02:47
2.1K0
发布2021-06-25 00:02:47
举报
文章被收录于专栏:从零开始学自动化测试

前言

Airtest 生成报告的时候,每个不走都会自动带上截图,也可以自己添加截图,使用 snapshot()方法

snapshot 方法使用

对目标设备进行一次截图,并且保存到文件中。

参数:

  • filename – 保存截图的文件名,默认保存路径为 ST.LOG_DIR
  • msg – 截图文件的简短描述,将会被显示在报告页面中
  • quality – 图片的质量,[1,99]的整数,默认是10
  • max_size – 图片的最大尺寸,例如 1200

返回: 截图文件的绝对路径 支持平台: Android, iOS, Windows

示例:

代码语言:javascript
复制
>>> snapshot(msg="index")
>>> # save the screenshot to test.jpg
>>> snapshot(filename="test.png", msg="test")

可以设置截图的画质和大小

代码语言:javascript
复制
>>> # 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 屏幕截图

查看报告,显示截图

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-06-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 从零开始学自动化测试 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • snapshot 方法使用
  • 截图使用
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档