zoukankan      html  css  js  c++  java
  • Airtest 常用方法

    1.导包
    from airtest.core.api import *
    from airtest.core.api import using
    using("timeDecorator.air")
    from timeDecorator import count_time #导入count_time方法


    2. connect_device("Android:///")
    (1) 连接本地真机设备
    connect_device("Android:///SJE5T17B17?cap_method=javacap&touch_method=adb")
    (2) 连接模拟器
    connect_device("Android://127.0.0.1:5037/10.254.60.1:5555")
    常见模拟器端口号:
    网易mumu模拟器 7555
    夜神模拟器 62001


    3.auto_setup(basedir=None,devices=None,logdir=None,project_root=None,compress=0)
    自动配置运行环境,如果当前没有连接设备,默认尝试连接Android设备
    参数
    ·basedir -设置当前脚本所在路径,也可以直接传__file__变量进来
    ·devices - 一个内容为connect_device uri 字符串的列表
    ·logdir - 可设置脚本运行时log保存路径,默认值为None则不保存log,如果设置为True则自动保存在<basedir>/log目录中
    ·project_root - 用于设置PROJECT_ROOT变量,方便using接口的调用


    4. shell(*args, **kwargs)# 在目标设备上运行远程命令shell命令
    dev = connect_device("Android:///device1")
    dev.shell("ls")
    dev.shell('input text "test"') #输入test


    5. start_app() #在设备上启动目标应用,传的是包名
    start_app("com.tencent.qq")


    6. stop_app() #在设备上停止目标应用,传的是包名
    stop_app("com.tencent.qq")
    7. clear_app() # 清理设备上的目标应用数据,传的是包名 

    clear_app("com.tencent.qq")


    8. install() 安装应用到设备
    install(r"D:demo est.apk")


    9. uninstall ()#传入的是包名
    uninstall("com.tencent.qq")


    10. snapshot() #对目标设备进行一次截图,并且保存到文件中
    11. wake() #唤醒并解锁目标设备
    12. home() #返回home页面


    13. touch() # 在当前设备画面上 进行一次点击
    (1) 点击绝对坐标touch((100, 100))
    (2) 点击图片的中心位置
    touch(Template(r"tpl1606730579419.png", target_pos=5)
    (3) 点击两次 touch((100,100),times=2)


    14. click() #点击动作,比较常用
    15. double_click() #双击


    16. swipe() #滑动页面
    (1) swipe((100, 100), (200, 200))


    17. keyevent() #键盘事件 稍后给出键盘事件
    (1) keyevent("KEYCODE_DEL")
    (2) keyevent("HOME")


    18. text() #输入文本,文本框需要处于激活状态
    (1) text("test")
    (2) text("test", enter=False)
    (3) text("test", search=True)


    19. sleep()#设置一个等待sleep时间
    20. wait() #设置一个等待时间直到出现目标图片


    21. exists() #判断是否存在,如果存在返回坐标,否则返回false
    if exists(截图):
    22. find_all() #在设备屏幕上查找所有出现的目标并返回其坐标列表


    23. 断言
    (1) assert_exists()
    (2) assert_not_exists()
    (3) assert_equal
    (4) assert_not_equal

  • 相关阅读:
    根据科目计算父科目ID,并递归累计求父科目的金额
    xshell连接中标麒麟
    查看linux版本
    虚拟机的Vmtools
    apt-get和yum
    1264
    使用navicat的坑
    Qt bug
    模板函数举例
    头文件里声明和定义,Qt编译不过问题
  • 原文地址:https://www.cnblogs.com/eosclover/p/15004266.html
Copyright © 2011-2022 走看看