安裝
官網下載客戶端
airtest庫安裝
pip install airtest
pip install pocoui
腳本錄制
利用airtest客戶端錄制腳本
web端輔助插件-selenium windows打開:
設置chrome路徑
開始調式錄制
腳本運行
# -*- coding: utf-8 -*-
"""
@Time : 2024/5/23 15:44
@Auth : 團長
@File :run.py
"""
import subprocess
import os
import re
from airtest.report.report import LogToHtmlclass Run():def __init__(self):self.BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "\\VOC"def get_case_path(self):folder_names = [folder for folder in os.listdir(self.BASE_DIR) ifos.path.isdir(os.path.join(self.BASE_DIR, folder))]folders_names = []for folder in folder_names:if re.search("(.air)$", folder):folders_names.append(self.BASE_DIR + "\\" + folder)return folders_namesdef run_case(self, casePath):self.log_dir =self.BASE_DIR + "\\log"subprocess.call(f"""D:\python3.11\python.exe C:\\Users\\WS\\Downloads\\AirtestIDE-win-1.2.17\\AirtestIDE\\sample\\custom_launcher.py {casePath} --device Windows:/// --log {self.log_dir} """,shell=True)def case_report(self, casePath):h1 = LogToHtml(script_root=casePath,log_root=self.BASE_DIR + "\\log",export_dir="",logfile=self.BASE_DIR + "\\log\\log.txt",lang='zh', plugins=["airtest_selenium.report"])h1.report()if __name__ == "__main__":run=Run()# # #獲取用例路徑case_path_list=run.get_case_path()# #運行用例for case in case_path_list:run.run_case(case)# #獲取報告# for case in case_path_list:casePath="E:\\project\\cloud\\VOC\\voc_picture_large.air"run.case_report(casePath)