• 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')

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

    最后,放一个图感受一下

  • 相关阅读:
    Magic-Club开发--第十六天
    (待完成)
    (转)Python多任务之线程
    (转)机器学习常用性能度量中的Accuracy、Precision、Recall、ROC、F score等都是些什么东西?
    排序
    一些c++<new(std::nothrow) >
    一些c++<省去警告>
    一些c++<MFC
    一些c++<auto>
    Unity3D js和C# 间相互调用
  • 原文地址:https://www.cnblogs.com/kknote/p/16103482.html
Copyright © 2020-2023  润新知