__author__ = "sunkx" from airtest.core.api import * from airtest.cli.parser import cli_setup import logging logger = logging.getLogger("airtest") logger.setLevel(logging.ERROR) if not cli_setup(): auto_setup(__file__, logdir=True, devices=[ "android:/‘这块是手机的devices信息,每个手机都不一样’ ]) from poco.drivers.android.uiautomation import AndroidUiautomationPoco poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False) # 切换亮度函数,别问为什么要等待那么久,懂得都懂! def swipe_brightness(): poco.swipe([0.742, 0.764], [0.5, 0.766]) # 100亮度至5成 sleep(4) poco.swipe([0.5, 0.766], [0.357, 0.764]) # 5成至2成 sleep(3) poco.swipe([0.357, 0.764], [0.742, 0.764]) # 2成至100 sleep(4) for i in range(123, 10001): print(f'目前是第{i}次测试') poco("com.元素对象.smarthome:id/open_button").click() # 打开 poco.swipe([0.784, 0.587], [0.525, 0.512]) # 冷至中 sleep(5) swipe_brightness() # 亮度调节 测试 poco.swipe([0.525, 0.512], [0.211, 0.609]) # 中至暖 sleep(5) swipe_brightness() # 亮度调节 poco("com.元素对象.smarthome:id/open_button").click() # 关闭 sleep(5) poco("com.元素对象.smarthome:id/open_button").click() # 打开 poco.swipe([0.211, 0.609], [0.525, 0.512]) # 暖至中 sleep(5) swipe_brightness() # 亮度调节测试 poco.swipe([0.525, 0.512], [0.784, 0.587]) # 中至冷 swipe_brightness() poco("com.元素对象.smarthome:id/open_button").click() # 关闭 # generate html report from airtest.report.report import simple_report simple_report(__file__, logpath=True)
APP-airtest实行控制某一智能家居系统产品-模拟用户使用的场景压力
于 2023-07-25 16:11:05 首次发布