简易模拟点击自动化测试工具介绍

简要框架设计图

目前简易框架目录

 其中:

cmd_deivces.py 是设备管理类,设备相关信息处理都放在此类中

cmd_command.py 是公共方法类,测试用例的相关处理都放在此类中

exc_testcases.py 是测试用例类,测试用例都放在此类中

现阶段主要快速适用于适配线项目而设计

exc_testcases.py

# author=Five
# coding=utf-8
from cmd_command import cmd_command as cc
from random import randint


# 执行点击事件
def rand_tap_test(a, b):
    step.exec_tap(a, b)


# 执行滑动事件
def rand_swipe_test(c, e, d, f):
    step.exec_swipe(c, e, d, f)


# 执行输入事件
def rand_text_test(text):
    step.exec_text(text)


# 所有互联卡片及区域随机点击
def test_all_area():
  # 600表示我们需要执行的测试次数
for i in range(1, 600): # 右侧投屏区域控制 x = randint(180, 1900) y = randint(20, 700) # 右侧投屏区域滑动控制 x1 = randint(730, 1100) x2 = randint(1101, 1790) y1 = randint(90, 450) y2 = randint(451, 700) # systemUI区域控制 xx = randint(180, 550) xy = randint(80, 690) flag = i % 10
      # 控制各事件的触发比例 if flag in (2, 4, 6, 8, 10):
        # 调用点击事件 rand_tap_test(xx, xy)
elif flag in (1, 7):
        # 调用滑动事件 rand_swipe_test(x1, x2, y1, y2)
else:
        # 调用点击事件 rand_tap_test(x, y)
if __name__ == "__main__": step = cc() test_all_area()

主要设计思路:在指定区域内模拟手动点击和滑动等快速操作,保证可以只在关注的某一个功能内进行测,做持续化测试。

可以在exc_testcases.py中自定义方法,用于具体模块部分业务能力的自动化测试。

备注:重点是要确定点击和滑动的坐标区域范围

原文地址:https://www.cnblogs.com/wx2017/p/14781374.html