1 Star 3 Fork 2

booven / iosMonkey

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
booven 提交于 2023-11-20 17:05 . fix bug~
import requests.exceptions
import wda, random
from typing import Literal
from driver.driver import Driver
from time import sleep
from logger.logger import logger
from airtest.report.report import simple_report
from airtest.cli.parser import cli_setup
from airtest.core.api import auto_setup
from config import BASE_PATH
from conn.conn import check_crash
def run(count=100, throttle=0, swipe_rate=3,
click_type: Literal["coordinate", "element"] = "coordinate"):
"""
:param count: 事件数量
:param throttle: 时间间隔
:param swipe_rate: 滑动事件概率,8 => 1/8
:param click_type: 点击事件类型 "coordinate" -> 坐标(推荐使用) | "element" -> 元素(效率低)
:return:
"""
# 清理数据
d = Driver()
logger.info("iosMonkey测试开始执行".center(50, "="))
logger.info(f"执行事件次数:{count}")
logger.info(f"事件间隔时间:{throttle}")
logger.info(f"滑动事件概率:{1 / swipe_rate}")
logger.info(f"点击事件概率:{(swipe_rate - 1) / swipe_rate}")
logger.info(f"点击事件类型:{click_type}")
num = 1
for i in range(count):
event = random.randint(1, swipe_rate)
if event == 1:
d.scroll(num)
num += 1
else:
if click_type == "coordinate":
d.click_by_tap(num)
num += 1
elif click_type == "element":
d.click_by_ele(num)
num += 1
d.click_by_ele(num)
num += 1
d.click_by_ele(num)
num += 1
else:
raise Exception("没有这种点击方式")
sleep(throttle)
logger.info("iosMonkey测试结束执行".center(50, "="))
def generate_report():
logger.info("测试报告生成中, 请稍后···")
simple_report(__file__, logpath=True)
logger.info("测试报告已生成~")
if __name__ == '__main__':
try:
if not cli_setup():
auto_setup(__file__, logdir=True, devices=["IOS:///127.0.0.1:8100", ], project_root=BASE_PATH)
run(5000)
except Exception as err:
check_crash()
generate_report()
raise Exception
1
https://gitee.com/bohnyoung/ios-monkey.git
git@gitee.com:bohnyoung/ios-monkey.git
bohnyoung
ios-monkey
iosMonkey
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891