python+Airtest+android使用AirtestIDE编写一个DEMO

使用Airtest专用的编辑器AirtestIDE编写一个DEMO

1. 简介

AirtestIDE 是一个跨平台的UI自动化测试编辑器,适用于游戏和App。

  • 自动化脚本录制、一键回放、报告查看,轻而易举实现自动化测试流程
  • 支持基于图像识别Airtest框架,适用于所有Android/iOS/Windows应用
  • 支持基于UI控件搜索的Poco框架,适用于Unity3d,Cocos2d与Android/iOS App等多种平台
  • 能够运行在Windows和MacOS上
  • 完全基于python实现,脚本的语言完全跟随python,调用airtest的api
  • 录制的脚本基本没有冗余的代码(可能是我的脚本太简单,原谅我的无知哈)

2. 脚本做的事情

以下四步循环执行十次

第一步:在桌面点击电话

第二步:拨打136xxxxxxxx

第三步:因为手机没有sim卡,弹出提示,点下知道了回到通话记录界面

第四步:返回home

3. 脚本代码

# -*- encoding=utf8 -*-
__author__ = "kangpc"

from airtest.core.api import *
from airtest.cli.parser import cli_setup

if not cli_setup():
    auto_setup(__file__, logdir=True, devices=[
            "android://127.0.0.1:5037/8KE5T20103001133?cap_method=MINICAP_STREAM&&ori_method=MINICAPORI&&touch_method=MINITOUCH",
    ])


# script content
print("start...")
counter = 1
while(counter<10):
    touch(Template(r"tpl1606402338314.png", record_pos=(-0.352, 0.922), resolution=(1079, 2340)))
    touch(Template(r"tpl1606402344894.png", record_pos=(-0.203, -0.589), resolution=(1079, 2340)))
    touch(Template(r"tpl1606402415335.png", record_pos=(-0.005, 0.965), resolution=(1079, 2340)))
    keyevent("BACK")
    assert_exists(Template(r"tpl1606403009349.png", record_pos=(0.019, 0.039), resolution=(1079, 2340)), "检查当前是否在HOME页")
    counter+=1

# generate html report
# from airtest.report.report import simple_report
# simple_report(__file__, logpath=True)

4. 另一个脚本(点击+输入手机号)

# -*- encoding=utf8 -*-
__author__ = "kangpc"

from airtest.core.api import *
from airtest.cli.parser import cli_setup

if not cli_setup():
    auto_setup(__file__, logdir=True, devices=[
            "android://127.0.0.1:5037/8KE5T20103001133?cap_method=MINICAP_STREAM&&ori_method=MINICAPORI&&touch_method=MINITOUCH",
    ])


# script content
print("start...")
touch(Template(r"tpl1606405873959.png", record_pos=(0.12, 0.306), resolution=(1079, 2340)))
touch(Template(r"tpl1606405887402.png", record_pos=(0.212, 1.028), resolution=(1079, 2340)))
sleep(3)
touch(Template(r"tpl1606405894150.png", record_pos=(0.029, 0.488), resolution=(1079, 2340)))
sleep(3)
touch(Template(r"tpl1606405999074.png", record_pos=(-0.087, -0.436), resolution=(1079, 2340)))
sleep(3)
text('13600000000')

通过录制方式来点点点生成脚本

 

最后,放一个图感受一下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我是一言

让我看看你的头像

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值