import sys import os # 获取当前脚本的绝对路径 current_dir = os.path.dirname(os.path.abspath(__file__)) # 构建预定系统的绝对路径 预定系统_path = os.path.abspath(os.path.join(current_dir, '..', '..', '..')) # 添加路径 sys.path.append(预定系统_path) # 导入模块 from 预定系统.Base.base import * # 获取当前脚本所在的目录 current_dir = os.path.dirname(os.path.abspath(__file__)) # 构建XLSX文件的绝对路径 xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') class MessageApproval: tags = ['新-会议审批测试', 'JSON测试'] """ 执行指令是: 1.cd 预定系统 2.hytest --report_title 会议审批测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议审批测试 """ def teststeps(self): """ 执行测试步骤函数,主要用于执行读取的测试用例并进行会议模板模块功能测试操作 """ # 从全局存储中获取webdriver对象 wd = GSTORE['wd'] # 读取Excel文件中的测试用例数据 ddt_cases = read_xlsx_data(xlsx_file_path, "会议审批") # 遍历 ddt_cases 并获取每一个 JSON 对象 for case in ddt_cases: # 创建审批会议 meeting_message("审批会议室", "普通会议", "审批测试会议","标准版", wd) for step in case: print(f"当前步骤: {step}") # 先赋值 locator_type = get_by_enum(step.get('locator_type')) locator_value = step.get('locator_value') element_type = step.get('element_type') element_value = step.get('element_value') expented_result = step.get('expented_result') # 判断页面功能类型 if step.get("page") == "ApprovalInitiate": # 这是编辑模板测试 if element_type == "input": safe_send_keys((locator_type, locator_value), element_value, wd) sleep(1) elif element_type == "click": safe_click((locator_type, locator_value), wd) sleep(2) elif element_type == "getTips": notify_text = get_notify_text(wd, (locator_type, locator_value), "Message_Template", "Template_Edit", "编辑模板") INFO(f"提示信息为:{notify_text}") CHECK_POINT("编辑测试判断是否正确", expented_result in notify_text) SELENIUM_LOG_SCREEN(wd, "50") elif element_type == "getText": notify_text = elment_get_text((locator_type, locator_value), wd) INFO(f"获取文本信息为:{notify_text}") CHECK_POINT("获取文本判断是否正确", expented_result in notify_text) SELENIUM_LOG_SCREEN(wd, "50") # 取消审批会议数据 safe_click((By.XPATH, "//span[contains(text(),'取消审批')]"), wd) sleep(1) safe_click((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确定')]"), wd)