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 EditMessage: tags = ['新-会议修改测试', 'JSON测试'] """ 执行指令是: 1.cd 预定系统 2.hytest --report_title 会议修改测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议修改测试 """ ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议修改') # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议修改', columns_to_clear=['测试结果', '测试频次', '日志截图']) def teststeps(self): """ 执行测试步骤函数,主要用于执行读取的测试用例并进行会议修改界面操作测试 """ # 从全局存储中获取webdriver对象 wd = GSTORE['wd'] name = self.name # 调用会议创建函数 meeting_message("预约会议室", "普通会议", "普通会议", "标准版", wd) # 搜索会议 safe_send_keys((By.XPATH, "//input[@placeholder='输入关键字搜索']"), "普通会议", wd) send_keyboard((By.XPATH, "//input[@placeholder='输入关键字搜索']"), wd) sleep(1) # 点击会议修改按钮 safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'修改会议')]"), wd) for step in self.para: # 赋值页面类型page page_type = step.get('page') # 赋值元素定位类型,并将字符串转为Enum类型 locator_type = get_by_enum(step.get('locator_type')) # 赋值元素值 locator_value = step.get('locator_value') # 赋值元素类型,例如:click点击、input输入框等 element_type = step.get('element_type') # 赋值元素值,例如输入框的输入值 element_value = step.get('element_value') # 赋值预期结果 expented_result = step.get('expented_result') # 将会议名称赋值,后面调用函数结束会议 message_name = element_value # 判断页面功能类型 if page_type == "MessageNameTest": # 这是会议名称字符测试用例 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) safe_click((locator_type, locator_value), wd) sleep(2) elif element_type == "getText": # 搜索会议数据,获取会议列表的会议名称 safe_send_keys((locator_type, locator_value), element_value, wd) send_keyboard((locator_type, locator_value), wd) sleep(2) # 获取提示文本 notify_text = elment_get_text( (By.CSS_SELECTOR, "tbody tr[class='el-table__row'] td:nth-child(2) div:nth-child(1)"), wd) INFO(f"查询已预定列表的会议名称为:{notify_text}") CHECK_POINT("判断会议是否创建成功", expented_result in notify_text) SELENIUM_LOG_SCREEN(wd, "50") # 调用会议删除函数 INFO("调用会议删除函数") del_message(message_name, wd)