提交 0e883139 authored 作者: 陈泽健's avatar 陈泽健

优化read_xlsx_data用例文件读取函数,增加功能类别判断,实现标准版和各项目的区分执行。补充工商银行项目的车牌功能验证。config.json文件增加工商银行生产环境。

上级 80ebc0bc
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
"展厅统一平台巡检": "http://192.168.5.200:38083/#/login", "展厅统一平台巡检": "http://192.168.5.200:38083/#/login",
"展厅讯飞系统巡检": "http://192.168.5.201:8080/#/login", "展厅讯飞系统巡检": "http://192.168.5.201:8080/#/login",
"长安大学预定测试环境": "https://192.168.5.186/#/login/logindf", "长安大学预定测试环境": "https://192.168.5.186/#/login/logindf",
"工商银行项目生产环境": "https://192.168.52.63:21443/#/login/logindf" "工商银行项目生产环境": "https://192.168.52.62:20443/#/login/logindf"
} }
\ No newline at end of file
...@@ -477,13 +477,14 @@ def read_csv_data(csv_file_path): ...@@ -477,13 +477,14 @@ def read_csv_data(csv_file_path):
# 读取测试用例xlsx文件中的JSON数据进行数据驱动函数 # 读取测试用例xlsx文件中的JSON数据进行数据驱动函数
import openpyxl import openpyxl
def read_xlsx_data(xlsx_file_path, sheet_name=None): def read_xlsx_data(xlsx_file_path, sheet_name=None, case_type=None):
""" """
读取XLSX文件中的数据,并将其转换为一个包含字典的列表,每个字典代表一行测试用例数据。 读取XLSX文件中的数据,并将其转换为一个包含字典的列表,每个字典代表一行测试用例数据。
参数: 参数:
xlsx_file_path (str): XLSX文件的路径。 xlsx_file_path (str): XLSX文件的路径。
sheet_name (str, optional): 工作表的名称。如果未指定,则使用活动工作表。 sheet_name (str, optional): 工作表的名称。如果未指定,则使用活动工作表。
case_type (str, optional): 测试用例类型,例如 '标准版' 或 'XX项目需求'。如果未指定,则读取所有测试用例。
返回: 返回:
list: 包含字典的列表,每个字典包含测试用例的名称和参数。 list: 包含字典的列表,每个字典包含测试用例的名称和参数。
...@@ -511,12 +512,17 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None): ...@@ -511,12 +512,17 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None):
# 打印表头列名 # 打印表头列名
# INFO(f"表头列名: {headers}") # INFO(f"表头列名: {headers}")
# 找到表头中名为 'JSON' 的列索引 # 找到表头中名为 'JSON' 和 '功能类别' 的列索引
try: try:
json_index = headers.index('JSON') json_index = headers.index('JSON')
except ValueError as e: except ValueError as e:
raise ValueError(f"表头中没有找到所需的列: {e}") raise ValueError(f"表头中没有找到所需的列: {e}")
try:
category_index = headers.index('功能类别')
except ValueError as e:
raise ValueError(f"表头中没有找到所需的列: {e}")
ddt_cases = [] ddt_cases = []
# 遍历XLSX文件中的每一行数据,从第四行开始 # 遍历XLSX文件中的每一行数据,从第四行开始
for row_num, row in enumerate(sheet.iter_rows(min_row=4, values_only=True), start=4): for row_num, row in enumerate(sheet.iter_rows(min_row=4, values_only=True), start=4):
...@@ -524,7 +530,7 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None): ...@@ -524,7 +530,7 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None):
json_data = row[json_index] json_data = row[json_index]
# 打印 JSON 数据以进行调试 # 打印 JSON 数据以进行调试
# INFO(f"行 {row_num} 的 JSON 数据: {json_data}") INFO(f"行 {row_num} 的 JSON 数据: {json_data}")
# 检查 JSON 数据是否为空 # 检查 JSON 数据是否为空
if json_data is None or json_data.strip() == "": if json_data is None or json_data.strip() == "":
...@@ -537,6 +543,13 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None): ...@@ -537,6 +543,13 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None):
except json.JSONDecodeError: except json.JSONDecodeError:
raise ValueError(f"行 {row_num} 的 JSON 数据无法解析: {json_data}") raise ValueError(f"行 {row_num} 的 JSON 数据无法解析: {json_data}")
# 获取功能类别
category = row[category_index]
# 检查是否需要过滤测试用例类型
if case_type and category != case_type:
continue
# 将解析后的 JSON 数据添加到列表中 # 将解析后的 JSON 数据添加到列表中
ddt_cases.append(parsed_json) ddt_cases.append(parsed_json)
...@@ -545,6 +558,10 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None): ...@@ -545,6 +558,10 @@ def read_xlsx_data(xlsx_file_path, sheet_name=None):
# 返回包含所有测试用例数据的列表 # 返回包含所有测试用例数据的列表
return ddt_cases return ddt_cases
# if __name__ == "__main__":
# xlsx_file_path = r"C:\PycharmData\ubains-module-test\预定系统\测试数据\会议预定测试用例.xlsx"
# ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name="会议创建", case_type="工商银行项目-25-04-01")
# print(ddt_cases)
import openpyxl import openpyxl
import openpyxl import openpyxl
......
...@@ -279,3 +279,5 @@ ...@@ -279,3 +279,5 @@
- 处理工商银行JSON数据格式错误问题,处理优化。 - 处理工商银行JSON数据格式错误问题,处理优化。
76. 2025-04-08 76. 2025-04-08
- 缩短元素等待时间,调整展厅巡检视讯会议的会控按钮判断。增加议题文件上传未完成时点击【确定】弹出的确认框补充点击确认操作。 - 缩短元素等待时间,调整展厅巡检视讯会议的会控按钮判断。增加议题文件上传未完成时点击【确定】弹出的确认框补充点击确认操作。
77. 2025-04-09
- 优化read_xlsx_data用例文件读取函数,增加功能类别判断,实现标准版和各项目的区分执行。补充工商银行项目的车牌功能验证。config.json文件增加工商银行生产环境。
\ No newline at end of file
...@@ -23,7 +23,7 @@ class AIMeeting: ...@@ -23,7 +23,7 @@ class AIMeeting:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title AI创会测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-AI创会测试 2.hytest --report_title AI创会测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-AI创会测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='AI创会') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='AI创会',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='AI创会', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='AI创会', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class SMCMeeting: ...@@ -23,7 +23,7 @@ class SMCMeeting:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会控SMC测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会控SMC测试 2.hytest --report_title 会控SMC测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会控SMC测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会控-SMC') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会控-SMC',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-SMC', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-SMC', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class TxcentMeeting: ...@@ -23,7 +23,7 @@ class TxcentMeeting:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 腾讯会控测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会控腾讯测试 2.hytest --report_title 腾讯会控测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会控腾讯测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会控-腾讯会议') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会控-腾讯会议',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-腾讯会议', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-腾讯会议', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class EditMessage: ...@@ -23,7 +23,7 @@ class EditMessage:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议修改测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议修改测试 2.hytest --report_title 会议修改测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议修改测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议修改') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议修改',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议修改', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议修改', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class MeetingMessage: ...@@ -23,7 +23,7 @@ class MeetingMessage:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议创建测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议创建测试 2.hytest --report_title 会议创建测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议创建测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议创建') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议创建',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议创建', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议创建', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class HistoryMessage: ...@@ -23,7 +23,7 @@ class HistoryMessage:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议历史记录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议历史记录测试 2.hytest --report_title 会议历史记录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议历史记录测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议历史记录') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议历史记录',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议历史记录', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议历史记录', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class MessageApproval: ...@@ -23,7 +23,7 @@ class MessageApproval:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议审批测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议审批测试 2.hytest --report_title 会议审批测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议审批测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议审批') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议审批',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议审批', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议审批', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -24,7 +24,7 @@ class MeetingRoomList: ...@@ -24,7 +24,7 @@ class MeetingRoomList:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 账号密码登录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议室列表 2.hytest --report_title 账号密码登录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议室列表
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议室列表') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议室列表',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室列表', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室列表', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class ConferenceRoomManagement: ...@@ -23,7 +23,7 @@ class ConferenceRoomManagement:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议室管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议室管理测试 2.hytest --report_title 会议室管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议室管理测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议室管理') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议室管理',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室管理', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class MessageTemplate: ...@@ -23,7 +23,7 @@ class MessageTemplate:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议模板测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议模板测试 2.hytest --report_title 会议模板测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议模板测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议模板') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议模板',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议模板', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议模板', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class InformationDelivery: ...@@ -23,7 +23,7 @@ class InformationDelivery:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 信息发布测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-信息发布测试 2.hytest --report_title 信息发布测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-信息发布测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='信息发布') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='信息发布',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息发布', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息发布', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class InformationStatistics: ...@@ -23,7 +23,7 @@ class InformationStatistics:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 信息统计测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-信息统计测试 2.hytest --report_title 信息统计测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-信息统计测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='信息统计') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='信息统计',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息统计', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息统计', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class GlobalConfiguration: ...@@ -23,7 +23,7 @@ class GlobalConfiguration:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 全局配置测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-全局配置测试 2.hytest --report_title 全局配置测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-全局配置测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='全局配置') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='全局配置',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='全局配置', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='全局配置', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class AndroidInformation: ...@@ -23,7 +23,7 @@ class AndroidInformation:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 安卓信息测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-安卓信息测试 2.hytest --report_title 安卓信息测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-安卓信息测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='安卓信息') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='安卓信息',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='安卓信息', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='安卓信息', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class TokenManage: ...@@ -23,7 +23,7 @@ class TokenManage:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 授权码管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-授权码管理测试 2.hytest --report_title 授权码管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-授权码管理测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='授权码管理') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='授权码管理',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='授权码管理', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='授权码管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class Login: ...@@ -23,7 +23,7 @@ class Login:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 账号密码登录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-登录测试 2.hytest --report_title 账号密码登录测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-登录测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='登录页面') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='登录页面',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='登录页面', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='登录页面', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class SystemManage: ...@@ -23,7 +23,7 @@ class SystemManage:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 系统管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-系统管理测试 2.hytest --report_title 系统管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-系统管理测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='系统管理') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='系统管理',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='系统管理', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='系统管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -23,7 +23,7 @@ class AccountManagement: ...@@ -23,7 +23,7 @@ class AccountManagement:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 账号管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-账号管理测试 2.hytest --report_title 账号管理测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-账号管理测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='账号管理') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='账号管理',case_type="标准版")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='账号管理', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='账号管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
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 *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("工商银行项目生产环境")
user_login("admin", "Admin@88")
sleep(2)
wd = GSTORE['wd']
# 选择会议室进入创建会议界面
safe_click((By.XPATH, "//li[1]//div[1]//div[2]//span[1]"), wd)
sleep(1)
safe_click((By.XPATH, "//div[normalize-space()='23:55']"), wd)
sleep(1)
# 点击【下一步】按钮
safe_click((By.XPATH, "//div[contains(text(),'下一步')]"), wd)
sleep(1)
def suite_teardown():
wd = GSTORE['wd']
wd.quit()
\ No newline at end of file
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 *
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(预定系统_path, '测试数据', '会议预定测试用例.xlsx')
class LicensePlateFilling:
tags = ['工商银行项目会议修改车牌功能测试']
"""
执行指令是:
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='会议修改',case_type="工商银行项目-25-04-01")
# 测试开始前调用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
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')
INFO(f"页面: {page_type}、元素定位类型: {locator_type}、元素定位值: {locator_value}、元素类型: {element_type}、元素值: {element_value}、预期结果: {expented_result}")
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
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}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expented_result in text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
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 *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("工商银行项目生产环境")
user_login("admin", "Admin@88")
sleep(2)
wd = GSTORE['wd']
# 选择会议室进入创建会议界面
safe_click((By.XPATH, "//li[1]//div[1]//div[2]//span[1]"), wd)
sleep(1)
safe_click((By.XPATH, "//div[normalize-space()='23:55']"), wd)
sleep(1)
# 点击【下一步】按钮
safe_click((By.XPATH, "//div[contains(text(),'下一步')]"), wd)
sleep(1)
def suite_teardown():
wd = GSTORE['wd']
wd.quit()
\ No newline at end of file
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 *
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(预定系统_path, '测试数据', '会议预定测试用例.xlsx')
class LicensePlateFilling:
tags = ['工商银行项目会议预定车牌功能测试']
"""
执行指令是:
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='会议创建',case_type="工商银行项目-25-04-01")
# 测试开始前调用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
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')
INFO(f"页面: {page_type}、元素定位类型: {locator_type}、元素定位值: {locator_value}、元素类型: {element_type}、元素值: {element_value}、预期结果: {expented_result}")
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
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}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expented_result in text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
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 *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("工商银行项目生产环境")
user_login("admin", "Admin@88")
sleep(2)
wd = GSTORE['wd']
# 点击后台管理
safe_click((By.XPATH, "//img[@title='后台系统']"), wd)
sleep(1)
# 展开会议室管理
safe_click((By.XPATH, "//span[contains(text(),'会议室管理')]"), wd)
sleep(1)
# 点击【会议室管理】进入
safe_click((By.XPATH, "//li[contains(text(),'会议室管理')]"), wd)
sleep(1)
def suite_teardown():
wd = GSTORE['wd']
wd.quit()
\ No newline at end of file
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 *
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(预定系统_path, '测试数据', '会议预定测试用例.xlsx')
class MeetingRoomSynchronization:
tags = ['工商银行项目会议室同步功能测试']
"""
执行指令是:
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='会议室管理',case_type="工商银行项目-25-04-01")
# 测试开始前调用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
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')
INFO(f"页面: {page_type}、元素定位类型: {locator_type}、元素定位值: {locator_value}、元素类型: {element_type}、元素值: {element_value}、预期结果: {expented_result}")
if element_type == "click":
if "同步" in locator_value:
safe_click((locator_type, locator_value), wd)
sleep(90)
else:
safe_click((locator_type, locator_value), wd)
sleep(2)
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
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}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expented_result in text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
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 *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("工商银行项目生产环境")
user_login("admin", "Admin@88")
sleep(2)
wd = GSTORE['wd']
# 点击【历史记录】按钮进入模块界面
safe_click((By.XPATH, "//span[contains(text(),'历史记录')]"), wd)
sleep(1)
def suite_teardown():
wd = GSTORE['wd']
wd.quit()
\ No newline at end of file
...@@ -20,7 +20,7 @@ class AccountManagement: ...@@ -20,7 +20,7 @@ class AccountManagement:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 工商银行项目测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 工商银行OA组织架构同步 2.hytest --report_title 工商银行项目测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 工商银行OA组织架构同步
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='账号管理') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='账号管理',case_type="工商银行项目-25-04-01")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='账号管理', columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='账号管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
...@@ -20,7 +20,7 @@ class ChangAnMessageApproval: ...@@ -20,7 +20,7 @@ class ChangAnMessageApproval:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 长安大学取消审批测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 长安大学取消审批测试 2.hytest --report_title 长安大学取消审批测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 长安大学取消审批测试
""" """
ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议审批') ddt_cases = read_xlsx_data(xlsx_file_path, sheet_name='会议审批',case_type="长安大学项目25-03-17")
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空 # 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议审批',columns_to_clear=['测试结果', '测试频次', '日志截图']) clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议审批',columns_to_clear=['测试结果', '测试频次', '日志截图'])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论