提交 76a8ce14 authored 作者: 陈泽健's avatar 陈泽健

feat(预定系统): 添加标准版快速测试功能

- 新增标准版快速测试套件初始化与清理逻辑
- 实现定时每两小时执行一次快速测试任务
- 创建预定功能测试用例读取与执行模块
- 支持从Excel文件加载测试数据并运行自动化测试
- 增加页面点击、输入、窗口切换等操作的安全封装
- 集成登录、提示信息获取、文本验证等测试步骤
- 添加测试截图日志记录功能便于问题追踪
上级 305b9662
import sys
import os
from hytest import *
# 获取 Base 目录的绝对路径,并加入 sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
from 预定系统.Base.base import *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("标准版预定系统")
# user_login("admin@Test", "Ubains@4321")
sleep(2)
wd = GSTORE['wd']
# # 进入后台模块
# safe_click((By.XPATH, "//img[@title='后台系统']"),wd)
# # 展开全局配置模块
# safe_click((By.XPATH, "//span[contains(text(),'授权码管理')]"), wd)
# sleep(1)
# # 进入全局配置界面
# safe_click((By.XPATH, "//li[contains(text(),'授权码管理')]"), wd)
def suite_teardown():
wd = GSTORE['wd']
wd.quit()
\ No newline at end of file
import sys
import os
# 获取 Base 目录的绝对路径,并加入 sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
from 预定系统.Base.base import *
# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定快速测试用例.xlsx')
class MeetingManageQuickTest:
tags = ['预定系统快速测试']
"""
执行指令是:
1.cd 预定系统
2.hytest --report_title 预定系统快速测试测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 预定系统快速测试
"""
ddt_cases = read_xlsx_data(xlsx_file_path, case_type="标准版")
def teststeps(self):
"""
执行测试步骤函数,主要用于执行读取的测试用例并进行信息统计模块功能测试操作
"""
# 从全局存储中获取webdriver对象
wd = GSTORE['wd']
name = self.name
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')
# 赋值预期结果
expected_result = step.get('expected_result')
# 赋值等待时间
# sleep_time = step.get('sleep_time')
INFO(
f"页面: {page_type}、元素定位类型: {locator_type}、元素定位值: {locator_value}、元素类型: {element_type}、元素值: {element_value}、预期结果: {expected_result}")
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "SwitchWindow":
# 将字符转换为int类型
element_value = int(element_value)
wd.switch_to.window(wd.window_handles[element_value])
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "login":
# 退出系统登录
safe_click((By.XPATH, "//div[@class='quit']"), wd)
sleep(2)
INFO(f"开始登录,账号为:{element_value[0]},密码为:{element_value[1]}")
user_login(element_value[0], element_value[1])
sleep(2)
elif element_type == "getTips":
notify_text = get_notify_text(wd, (locator_type, locator_value))
INFO(f"获取到的提示信息为:{notify_text}")
sleep(2)
CHECK_POINT(f"获取到的提示信息为:{notify_text}", expected_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expected_result in text)
SELENIUM_LOG_SCREEN(wd, "75")
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -85,8 +85,8 @@ start_workers(3)
# 定时执行预定系统测试任务
schedule.every().day.at("10:00").do(run_task, run_automation_test, report_title="预定系统测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="预定系统测试", ding_type="标准版巡检")
# schedule.every().day.at("07:00").do(run_task, run_automation_test, report_title="兰州中石化项目测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="兰州中石化项目", ding_type="标准版巡检")
# 定时每一小时执行一次预定快速测试任务
schedule.every(2).hours.do(run_task, run_automation_test, report_title="预定系统快速测试测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="预定系统快速测试", ding_type="标准版巡检")
# 定时执行展厅巡检任务
# schedule.every().day.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31136", test_case="展厅巡检", ding_type="展厅巡检")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论