提交 6ec99032 authored 作者: 陈泽健's avatar 陈泽健

处理会议测试用例所有模块的JSON数据格式以及代码处理,规范化类名。

上级 93803d12
...@@ -268,4 +268,5 @@ ...@@ -268,4 +268,5 @@
- 实现通过JSON数据中对应的name值来区分测试用例数量。 - 实现通过JSON数据中对应的name值来区分测试用例数量。
- 补充write_xlsx_data函数用以将测试结果与日志截图写入到xlsx测试用例文件中。调试write_xlsx_data函数与统一平台的窗口切换关闭。 - 补充write_xlsx_data函数用以将测试结果与日志截图写入到xlsx测试用例文件中。调试write_xlsx_data函数与统一平台的窗口切换关闭。
72. 2025-03-24 72. 2025-03-24
- 优化write_xlsx_data函数实现表格自动填充测试结果和日志截图功能。 - 优化write_xlsx_data函数实现表格自动填充测试结果和日志截图功能。
\ No newline at end of file - 处理会议测试用例所有模块的JSON数据格式以及代码处理,规范化类名。
\ No newline at end of file
...@@ -23,33 +23,36 @@ class AIMeeting: ...@@ -23,33 +23,36 @@ 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创会')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='AI创会', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
wd = GSTORE['wd'] wd = GSTORE['wd']
ddt_cases = read_xlsx_data(xlsx_file_path, "AI创会") name = self.name
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
page_type = step.get('page')
for step in case: # 赋值元素定位类型,并将字符串转为Enum类型
print(f"当前步骤: {step}") locator_type = get_by_enum(step.get('locator_type'))
# 先赋值 # 赋值元素值
locator_type = get_by_enum(step.get('locator_type')) locator_value = step.get('locator_value')
locator_value = step.get('locator_value') # 赋值元素类型,例如:click点击、input输入框等
element_type = step.get('element_type') element_type = step.get('element_type')
element_value = step.get('element_value') # 赋值元素值,例如输入框的输入值
expented_result = step.get('expented_result') element_value = step.get('element_value')
# 将会议名称赋值,后面调用函数结束会议 # 赋值预期结果
message_name = element_value expented_result = step.get('expented_result')
# 判断页面功能类型 # 判断页面功能类型
if step.get("page") == "AIMeeting": if page_type == "AIMeeting":
if element_type == "input": if element_type == "input":
# 查询会议 # 查询会议
safe_send_keys((locator_type, locator_value), element_value, wd) safe_send_keys((locator_type, locator_value), element_value, wd)
send_keyboard((locator_type, locator_value), wd) send_keyboard((locator_type, locator_value), wd)
sleep(2) sleep(2)
elif element_type == "click": elif element_type == "click":
safe_click((locator_type, locator_value), wd) safe_click((locator_type, locator_value), wd)
sleep(2) sleep(2)
\ No newline at end of file \ No newline at end of file
...@@ -16,63 +16,69 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,63 +16,69 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class SMCMeeting_00x: class SMCMeeting:
tags = ['新-会控SMC测试', 'JSON测试'] tags = ['新-会控SMC测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-SMC', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
wd = GSTORE['wd'] wd = GSTORE['wd']
ddt_cases = read_xlsx_data(xlsx_file_path, "会控-SMC") name = self.name
# 调用会议创建函数
meeting_message("SMC会议室", "SMC3.0", "SMC3.0", "标准版", wd)
sleep(1)
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
# 调用会议创建函数 page_type = step.get('page')
meeting_message("SMC会议室", "SMC3.0", "SMC3.0", "标准版", wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(1) locator_type = get_by_enum(step.get('locator_type'))
for step in case: # 赋值元素值
print(f"当前步骤: {step}") locator_value = step.get('locator_value')
# 先赋值 # 赋值元素类型,例如:click点击、input输入框等
locator_type = get_by_enum(step.get('locator_type')) element_type = step.get('element_type')
locator_value = step.get('locator_value') # 赋值元素值,例如输入框的输入值
element_type = step.get('element_type') element_value = step.get('element_value')
element_value = step.get('element_value') # 赋值预期结果
expented_result = step.get('expented_result') expented_result = step.get('expented_result')
# 将会议名称赋值,后面调用函数结束会议 # 将会议名称赋值,后面调用函数结束会议
message_name = element_value message_name = element_value
# 判断页面功能类型 # 判断页面功能类型
if step.get("page") == "MeetingControl_SMC": if page_type == "MeetingControl_SMC":
if element_type == "input": if element_type == "input":
# 查询会议 # 查询会议
safe_send_keys((locator_type, locator_value), element_value, wd) safe_send_keys((locator_type, locator_value), element_value, wd)
send_keyboard((locator_type, locator_value), wd) send_keyboard((locator_type, locator_value), wd)
sleep(2) sleep(2)
# 提前开始会议 # 提前开始会议
safe_click((By.XPATH, "//span[contains(text(),'更多操作')]"), wd) safe_click((By.XPATH, "//span[contains(text(),'更多操作')]"), wd)
sleep(1) sleep(1)
safe_click((By.XPATH, "//li[contains(text(),'会议状态')]"), wd) safe_click((By.XPATH, "//li[contains(text(),'会议状态')]"), wd)
sleep(1) sleep(1)
safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd) safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd)
sleep(2) sleep(2)
elif element_type == "click": elif element_type == "click":
safe_click((locator_type, locator_value), wd) safe_click((locator_type, locator_value), wd)
sleep(2) sleep(2)
elif element_type == "getText": elif element_type == "getText":
# 切换到新窗口 # 切换到新窗口
wd.switch_to.window(wd.window_handles[1]) wd.switch_to.window(wd.window_handles[1])
notify_text = elment_get_text((locator_type, locator_value), wd) notify_text = elment_get_text((locator_type, locator_value), wd)
INFO(f"当前页面标题为:{notify_text}") INFO(f"当前页面标题为:{notify_text}")
CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text) CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50") SELENIUM_LOG_SCREEN(wd, "50")
# 切换窗口 # 切换窗口
wd.switch_to.window(wd.window_handles[0]) wd.switch_to.window(wd.window_handles[0])
wd.refresh() wd.refresh()
# 调用会议结束函数,传入会议名称 # 调用会议结束函数,传入会议名称
INFO(f"调用message_satus_control函数结束{message_name}名称的会议") INFO(f"调用message_satus_control函数结束{message_name}名称的会议")
message_satus_control(message_name, "会控", "提前结束", wd) message_satus_control(message_name, "会控", "提前结束", wd)
\ No newline at end of file \ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class TxcentMeeting_00x: class TxcentMeeting:
tags = ['新-会控腾讯测试', 'JSON测试'] tags = ['新-会控腾讯测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会控-腾讯会议')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会控-腾讯会议', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,53 +33,57 @@ class TxcentMeeting_00x: ...@@ -30,53 +33,57 @@ class TxcentMeeting_00x:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会控-腾讯会议")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
# 调用会议创建函数
meeting_message("腾讯会议室", "腾讯会议", "腾讯会议","标准版", wd)
sleep(1)
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')
# 将会议名称赋值,后面调用函数结束会议
message_name = element_value
# 判断页面功能类型 # 调用会议创建函数
if step.get("page") == "MeetingControl_Txcent": meeting_message("腾讯会议室", "腾讯会议", "腾讯会议", "标准版", wd)
if element_type == "input": sleep(1)
# 查询会议
safe_send_keys((locator_type, locator_value), element_value, wd)
send_keyboard((locator_type, locator_value), wd)
sleep(2)
# 提前开始会议
safe_click((By.XPATH, "//span[contains(text(),'更多操作')]"), wd)
sleep(1)
safe_click((By.XPATH, "//li[contains(text(),'会议状态')]"), wd)
sleep(1)
safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd)
sleep(2)
elif element_type == "click": for step in self.para:
safe_click((locator_type, locator_value), wd) # 赋值页面类型page
sleep(2) 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
elif element_type == "getText": # 判断页面功能类型
# 切换到新窗口 if page_type == "MeetingControl_Txcent":
wd.switch_to.window(wd.window_handles[1]) if element_type == "input":
notify_text = elment_get_text((locator_type,locator_value), wd) # 查询会议
INFO(f"当前页面标题为:{notify_text}") safe_send_keys((locator_type, locator_value), element_value, wd)
CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text) send_keyboard((locator_type, locator_value), wd)
SELENIUM_LOG_SCREEN(wd, "50") sleep(2)
# 切换窗口 # 提前开始会议
wd.switch_to.window(wd.window_handles[0]) safe_click((By.XPATH, "//span[contains(text(),'更多操作')]"), wd)
wd.refresh() sleep(1)
# 调用会议结束函数,传入会议名称 safe_click((By.XPATH, "//li[contains(text(),'会议状态')]"), wd)
INFO(f"调用message_satus_control函数结束{message_name}名称的会议") sleep(1)
message_satus_control(message_name, "会控", "提前结束", wd) safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd)
\ No newline at end of file sleep(2)
elif element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
elif element_type == "getText":
# 切换到新窗口
wd.switch_to.window(wd.window_handles[1])
notify_text = elment_get_text((locator_type, locator_value), wd)
INFO(f"当前页面标题为:{notify_text}")
CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
# 切换窗口
wd.switch_to.window(wd.window_handles[0])
wd.refresh()
# 调用会议结束函数,传入会议名称
INFO(f"调用message_satus_control函数结束{message_name}名称的会议")
message_satus_control(message_name, "会控", "提前结束", wd)
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class EditMessage_00x: class EditMessage:
tags = ['新-会议修改测试', 'JSON测试'] tags = ['新-会议修改测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议修改')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议修改', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,54 +33,58 @@ class EditMessage_00x: ...@@ -30,54 +33,58 @@ class EditMessage_00x:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议修改")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
# 调用会议创建函数
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 case: # 调用会议创建函数
print(f"当前步骤: {step}") meeting_message("预约会议室", "普通会议", "普通会议", "标准版", wd)
# 先赋值 # 搜索会议
locator_type = get_by_enum(step.get('locator_type')) safe_send_keys((By.XPATH, "//input[@placeholder='输入关键字搜索']"), "普通会议", wd)
locator_value = step.get('locator_value') send_keyboard((By.XPATH, "//input[@placeholder='输入关键字搜索']"), wd)
element_type = step.get('element_type') sleep(1)
element_value = step.get('element_value') # 点击会议修改按钮
expented_result = step.get('expented_result') safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'修改会议')]"), wd)
# 将会议名称赋值,后面调用函数结束会议
message_name = element_value
# 判断页面功能类型 for step in self.para:
if step.get("page") == "MessageNameTest": # 赋值页面类型page
# 这是会议名称字符测试用例 page_type = step.get('page')
if element_type == "input": # 赋值元素定位类型,并将字符串转为Enum类型
# 输入会议名称 locator_type = get_by_enum(step.get('locator_type'))
safe_send_keys((locator_type, locator_value), element_value, wd) # 赋值元素值
sleep(1) 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
elif element_type == "click": # 判断页面功能类型
safe_click((locator_type, locator_value), wd) if page_type == "MessageNameTest":
sleep(2) # 这是会议名称字符测试用例
if element_type == "input":
# 输入会议名称
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(1)
elif element_type == "getText": elif element_type == "click":
# 搜索会议数据,获取会议列表的会议名称 safe_click((locator_type, locator_value), wd)
safe_send_keys((locator_type, locator_value), element_value, wd) safe_click((locator_type, locator_value), wd)
send_keyboard((locator_type, locator_value), wd) sleep(2)
sleep(2)
# 获取提示文本 elif element_type == "getText":
notify_text = elment_get_text( # 搜索会议数据,获取会议列表的会议名称
(By.CSS_SELECTOR, "tbody tr[class='el-table__row'] td:nth-child(2) div:nth-child(1)"), safe_send_keys((locator_type, locator_value), element_value, wd)
wd) send_keyboard((locator_type, locator_value), wd)
INFO(f"查询已预定列表的会议名称为:{notify_text}") sleep(2)
CHECK_POINT("判断会议是否创建成功", expented_result in notify_text) # 获取提示文本
SELENIUM_LOG_SCREEN(wd, "50") notify_text = elment_get_text(
# 调用会议删除函数 (By.CSS_SELECTOR, "tbody tr[class='el-table__row'] td:nth-child(2) div:nth-child(1)"),
INFO("调用会议删除函数") wd)
del_message(message_name, wd) INFO(f"查询已预定列表的会议名称为:{notify_text}")
\ No newline at end of file CHECK_POINT("判断会议是否创建成功", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
# 调用会议删除函数
INFO("调用会议删除函数")
del_message(message_name, wd)
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class MeetingMessage_00x: class MeetingMessage:
tags = ['新-会议创建测试', 'JSON测试'] tags = ['新-会议创建测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议创建')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议创建', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,52 +33,56 @@ class MeetingMessage_00x: ...@@ -30,52 +33,56 @@ class MeetingMessage_00x:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议创建") # 调用进入会议预定界面函数
# 遍历 ddt_cases 并获取每一个 JSON 对象 enter_meeting_booking_page("预约会议室", wd)
for case in ddt_cases: sleep(1)
# 调用进入会议预定界面函数
enter_meeting_booking_page("预约会议室", wd)
sleep(1)
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')
# 将会议名称赋值,后面调用函数结束会议
message_name = element_value
# 判断页面功能类型 for step in self.para:
if step.get("page") == "MessageNameTest": # 赋值页面类型page
# 这是会议名称字符测试用例 page_type = step.get('page')
if element_type == "input": # 赋值元素定位类型,并将字符串转为Enum类型
# 输入会议名称 locator_type = get_by_enum(step.get('locator_type'))
safe_send_keys((locator_type, locator_value), element_value, wd) # 赋值元素值
sleep(1) 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')
elif element_type == "click": # 将会议名称赋值,后面调用函数结束会议
# 点击快速预定按钮 message_name = element_value
safe_click((locator_type, locator_value), wd)
safe_click((locator_type, locator_value), wd)
sleep(2)
safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'预定')]"), wd)
sleep(2)
elif element_type == "getText": # 判断页面功能类型
# 搜索会议数据,获取会议列表的会议名称 if page_type == "MessageNameTest":
safe_send_keys((locator_type, locator_value), element_value, wd) # 这是会议名称字符测试用例
send_keyboard((locator_type, locator_value), wd) if element_type == "input":
sleep(2) # 输入会议名称
# 获取提示文本 safe_send_keys((locator_type, locator_value), element_value, wd)
notify_text = elment_get_text( sleep(1)
(By.CSS_SELECTOR, "tbody tr[class='el-table__row'] td:nth-child(2) div:nth-child(1)"),
wd) elif element_type == "click":
INFO(f"查询已预定列表的会议名称为:{notify_text}") # 点击快速预定按钮
CHECK_POINT("判断会议是否创建成功", expented_result in notify_text) safe_click((locator_type, locator_value), wd)
SELENIUM_LOG_SCREEN(wd, "50") safe_click((locator_type, locator_value), wd)
# 调用会议删除函数 sleep(2)
INFO("调用会议删除函数") safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'预定')]"), wd)
del_message(message_name, wd) sleep(2)
\ No newline at end of file
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)
\ No newline at end of file
...@@ -16,46 +16,54 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,46 +16,54 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class HistoryMessage_00x: class HistoryMessage:
tags = ['新-会议历史记录测试', 'JSON测试'] tags = ['新-会议历史记录测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议历史记录')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议历史记录', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
执行测试步骤函数,主要用于执行读取的测试用例并进行会议预定界面操作 执行测试步骤函数,主要用于执行读取的测试用例并进行会议历史记录界面操作
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议历史记录")
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
for step in case: page_type = step.get('page')
print(f"当前步骤: {step}") # 赋值元素定位类型,并将字符串转为Enum类型
# 先赋值 locator_type = get_by_enum(step.get('locator_type'))
locator_type = get_by_enum(step.get('locator_type')) # 赋值元素值
locator_value = step.get('locator_value') locator_value = step.get('locator_value')
element_type = step.get('element_type') # 赋值元素类型,例如:click点击、input输入框等
element_value = step.get('element_value') element_type = step.get('element_type')
expented_result = step.get('expented_result') # 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 判断页面功能类型 # 赋值预期结果
if step.get("page") == "MessageQuery": expented_result = step.get('expented_result')
# 这是会议名称字符测试用例
if element_type == "input": # 判断页面功能类型
safe_send_keys((locator_type, locator_value), element_value, wd) if page_type == "MessageQuery":
sleep(2) # 这是会议名称字符测试用例
elif element_type == "click": if element_type == "input":
# 点击按钮 safe_send_keys((locator_type, locator_value), element_value, wd)
safe_click((locator_type, locator_value), wd) sleep(2)
sleep(2)
elif element_type == "getText": elif element_type == "click":
# 获取列表筛选数据 # 点击按钮
notify_text = elment_get_text((locator_type, locator_value), wd) safe_click((locator_type, locator_value), wd)
INFO(f"获取列表筛选数据:{notify_text}") sleep(2)
CHECK_POINT(f"判断列表筛选数据是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50") elif element_type == "getText":
\ No newline at end of file # 获取列表筛选数据
notify_text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取列表筛选数据:{notify_text}")
CHECK_POINT(f"判断列表筛选数据是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
...@@ -23,6 +23,9 @@ class MessageApproval: ...@@ -23,6 +23,9 @@ 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='会议审批')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议审批', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,45 +33,52 @@ class MessageApproval: ...@@ -30,45 +33,52 @@ class MessageApproval:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议审批") # 创建审批会议
# 遍历 ddt_cases 并获取每一个 JSON 对象 meeting_message("审批会议室", "普通会议", "审批测试会议", "标准版", wd)
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "ApprovalInitiate": # 赋值页面类型page
# 这是编辑模板测试 page_type = step.get('page')
if element_type == "input": # 赋值元素定位类型,并将字符串转为Enum类型
safe_send_keys((locator_type, locator_value), element_value, wd) locator_type = get_by_enum(step.get('locator_type'))
sleep(1) # 赋值元素值
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')
elif element_type == "click": # 判断页面功能类型
safe_click((locator_type, locator_value), wd) if page_type == "ApprovalInitiate":
sleep(2) # 这是编辑模板测试
if element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(1)
elif element_type == "getTips": elif element_type == "click":
notify_text = get_notify_text(wd, (locator_type, locator_value), "Message_Template", "Template_Edit", "编辑模板") safe_click((locator_type, locator_value), wd)
INFO(f"提示信息为:{notify_text}") safe_click((locator_type, locator_value), wd)
CHECK_POINT("编辑测试判断是否正确", expented_result in notify_text) sleep(2)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "getText": elif element_type == "getTips":
notify_text = elment_get_text((locator_type, locator_value), wd) notify_text = get_notify_text(wd, (locator_type, locator_value), "Message_Template",
INFO(f"获取文本信息为:{notify_text}") "Template_Edit", "编辑模板")
CHECK_POINT("获取文本判断是否正确", expented_result in notify_text) INFO(f"提示信息为:{notify_text}")
SELENIUM_LOG_SCREEN(wd, "50") CHECK_POINT("编辑测试判断是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
# 取消审批会议数据 elif element_type == "getText":
safe_click((By.XPATH, "//span[contains(text(),'取消审批')]"), wd) notify_text = elment_get_text((locator_type, locator_value), wd)
sleep(1) INFO(f"获取文本信息为:{notify_text}")
safe_click((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确定')]"), wd) CHECK_POINT("获取文本判断是否正确", expented_result in notify_text)
\ No newline at end of file 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)
\ No newline at end of file
...@@ -17,53 +17,59 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -17,53 +17,59 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class MeetingList_000x: class MeetingRoomList:
tags = ['新-会议室列表', 'JSON测试'] tags = ['新-会议室列表', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议室列表')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室列表', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
wd = GSTORE['wd'] wd = GSTORE['wd']
ddt_cases = read_xlsx_data(xlsx_file_path,"会议室列表") name = self.name
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
for step in case: page_type = step.get('page')
print(f"当前步骤: {step}") # 赋值元素定位类型,并将字符串转为Enum类型
if "MeetingRoomToken" in step.get("page"): locator_type = get_by_enum(step.get('locator_type'))
# 先赋值 # 赋值元素值
locator_type = get_by_enum(step.get('locator_type')) locator_value = step.get('locator_value')
locator_value = step.get('locator_value') # 赋值元素类型,例如:click点击、input输入框等
element_type = step.get('element_type') element_type = step.get('element_type')
element_value = step.get('element_value') # 赋值元素值,例如输入框的输入值
expented_result = step.get('expented_result') element_value = step.get('element_value')
# 赋值预期结果
expented_result = step.get('expented_result')
if element_type == "input": if page_type == "MeetingList_MeetingRoomToken":
# 点击展开筛选界面 if element_type == "input":
STEP(1, "搜索会议室") # 点击展开筛选界面
safe_send_keys((locator_type, locator_value), element_value, wd) STEP(1, "搜索会议室")
send_keyboard((locator_type, locator_value), wd) safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(2) send_keyboard((locator_type, locator_value), wd)
# 点击【查询】按钮 sleep(2)
safe_click((By.XPATH, "//span[contains(text(),'查询')]"), wd) # 点击【查询】按钮
sleep(1) safe_click((By.XPATH, "//span[contains(text(),'查询')]"), wd)
sleep(1)
elif element_type == "click": elif element_type == "click":
# 点击会议室,查看提示信息 # 点击会议室,查看提示信息
STEP(2, "点击【会议预约】") STEP(2, "点击【会议预约】")
safe_click((locator_type, locator_value), wd) safe_click((locator_type, locator_value), wd)
sleep(2) sleep(2)
# 判断是否为已授权的会议室,如果是,则点击会议预定判断是否进入会议预定界面,否则,点击会议预定,查看提示信息 # 判断是否为已授权的会议室,如果是,则点击会议预定判断是否进入会议预定界面,否则,点击会议预定,查看提示信息
if "会议" in expented_result: if "会议" in expented_result:
notify_text = elment_get_text((By.XPATH, "//div[@class='reserve_Title']"), wd) notify_text = elment_get_text((By.XPATH, "//div[@class='reserve_Title']"), wd)
else: else:
notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"), notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"),
"MeetingList", "RoomToken", f"未授权会议室点击【会议预定】") "MeetingList", "RoomToken", f"未授权会议室点击【会议预定】")
INFO(f"提示信息为:{notify_text}") INFO(f"提示信息为:{notify_text}")
# 判断提示信息是否正确 # 判断提示信息是否正确
sleep(1) sleep(1)
CHECK_POINT("提示信息是否正确", expented_result in notify_text) CHECK_POINT("提示信息是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50") SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file \ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class ConferenceStatistics: class ConferenceRoomManagement:
tags = ['新-会议室管理测试', 'JSON测试'] tags = ['新-会议室管理测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议室管理')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议室管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,31 +33,34 @@ class ConferenceStatistics: ...@@ -30,31 +33,34 @@ class ConferenceStatistics:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议室管理")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "ConferenceManageQuery": # 赋值页面类型page
safe_click((By.XPATH, "//li[contains(text(),'会议室管理')]"), wd) page_type = step.get('page')
if element_type == "click": # 赋值元素定位类型,并将字符串转为Enum类型
safe_click((locator_type, locator_value), wd) locator_type = get_by_enum(step.get('locator_type'))
sleep(2) # 赋值元素值
elif element_type == "input": locator_value = step.get('locator_value')
safe_send_keys((locator_type, locator_value), element_value, wd) # 赋值元素类型,例如:click点击、input输入框等
send_keyboard((locator_type, locator_value), wd) element_type = step.get('element_type')
sleep(2) # 赋值元素值,例如输入框的输入值
elif element_type == "getText": element_value = step.get('element_value')
notify_text = elment_get_text((locator_type, locator_value), wd) # 赋值预期结果
INFO(f"获取到的文本为:{notify_text}") expented_result = step.get('expented_result')
CHECK_POINT(f"判断查询结果是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50") # 判断页面功能类型
\ No newline at end of file if page_type == "ConferenceManageQuery":
safe_click((By.XPATH, "//li[contains(text(),'会议室管理')]"), wd)
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)
send_keyboard((locator_type, locator_value), wd)
sleep(2)
elif element_type == "getText":
notify_text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本为:{notify_text}")
CHECK_POINT(f"判断查询结果是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class MessageTemplate_00x: class MessageTemplate:
tags = ['新-会议模板测试', 'JSON测试'] tags = ['新-会议模板测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='会议模板')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='会议模板', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,33 +33,37 @@ class MessageTemplate_00x: ...@@ -30,33 +33,37 @@ class MessageTemplate_00x:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "会议模板")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "EditTemplate": # 赋值页面类型page
# 这是编辑模板测试 page_type = step.get('page')
if element_type == "input": # 赋值元素定位类型,并将字符串转为Enum类型
safe_send_keys((locator_type, locator_value), element_value, wd) locator_type = get_by_enum(step.get('locator_type'))
sleep(1) # 赋值元素值
elif element_type == "click": locator_value = step.get('locator_value')
safe_click((locator_type, locator_value), wd) # 赋值元素类型,例如:click点击、input输入框等
sleep(2) element_type = step.get('element_type')
elif element_type == "getTips": # 赋值元素值,例如输入框的输入值
notify_text = get_notify_text(wd, (locator_type, locator_value), "Message_Template", "Template_Edit", "编辑模板") element_value = step.get('element_value')
INFO(f"提示信息为:{notify_text}") # 赋值预期结果
CHECK_POINT("编辑测试判断是否正确", expented_result in notify_text) expented_result = step.get('expented_result')
SELENIUM_LOG_SCREEN(wd, "50")
# 切换至会议模板模块 # 判断页面功能类型
safe_click( if page_type== "EditTemplate":
(By.XPATH, "//ul[contains(@class,'meeting_list')]//span[contains(text(),'会议模板')]"), wd) # 这是编辑模板测试
\ No newline at end of file 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")
# 切换至会议模板模块
safe_click(
(By.XPATH, "//ul[contains(@class,'meeting_list')]//span[contains(text(),'会议模板')]"), wd)
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class AndroidInformation: class InformationDelivery:
tags = ['新-信息发布测试', 'JSON测试'] tags = ['新-信息发布测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='信息发布')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息发布', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,30 +33,33 @@ class AndroidInformation: ...@@ -30,30 +33,33 @@ class AndroidInformation:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "信息发布")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "AndroidInformation": # 赋值页面类型page
if element_type == "click": page_type = step.get('page')
safe_click((locator_type, locator_value), wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(2) locator_type = get_by_enum(step.get('locator_type'))
elif element_type == "input": # 赋值元素值
safe_send_keys((locator_type, locator_value), element_value, wd) locator_value = step.get('locator_value')
send_keyboard((locator_type, locator_value), wd) # 赋值元素类型,例如:click点击、input输入框等
sleep(2) element_type = step.get('element_type')
elif element_type == "getText": # 赋值元素值,例如输入框的输入值
notify_text = elment_get_text((locator_type,locator_value), wd) element_value = step.get('element_value')
INFO(f"获取的文本为:{notify_text}") # 赋值预期结果
CHECK_POINT("判断当前界面是否正确", expented_result in notify_text) expented_result = step.get('expented_result')
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file # 判断页面功能类型
if page_type == "MaterialManagement":
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)
send_keyboard((locator_type, locator_value), wd)
sleep(2)
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")
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class ConferenceStatistics: class InformationStatistics:
tags = ['新-信息统计测试', 'JSON测试'] tags = ['新-信息统计测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='信息统计')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='信息统计', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,24 +33,27 @@ class ConferenceStatistics: ...@@ -30,24 +33,27 @@ class ConferenceStatistics:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "信息统计")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "ConferenceStatistics": # 赋值页面page类型
if element_type == "click": page_type = step.get('page')
safe_click((locator_type, locator_value), wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(1) locator_type = get_by_enum(step.get('locator_type'))
SELENIUM_LOG_SCREEN(wd, "50") # 赋值元素值
elif element_type == "input": locator_value = step.get('locator_value')
safe_send_keys((locator_type, locator_value), element_value, wd) # 赋值元素类型,例如:click点击、input输入框等
\ No newline at end of file element_type = step.get('element_type')
# 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 赋值预期结果
expented_result = step.get('expented_result')
# 判断页面功能类型
if page_type == "ConferenceStatistics":
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(1)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
\ No newline at end of file
...@@ -23,6 +23,9 @@ class GlobalConfiguration: ...@@ -23,6 +23,9 @@ 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='全局配置')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='全局配置', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,25 +33,28 @@ class GlobalConfiguration: ...@@ -30,25 +33,28 @@ class GlobalConfiguration:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "全局配置")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "GlobalConfiguration": # 赋值页面类型page
if element_type == "click": page_type = step.get('page')
safe_click((locator_type, locator_value), wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(2) locator_type = get_by_enum(step.get('locator_type'))
SELENIUM_LOG_SCREEN(wd, "50") # 赋值元素值
elif element_type == "input": locator_value = step.get('locator_value')
safe_send_keys((locator_type, locator_value), element_value, wd) # 赋值元素类型,例如:click点击、input输入框等
sleep(2) element_type = step.get('element_type')
\ No newline at end of file # 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 赋值预期结果
expented_result = step.get('expented_result')
# 判断页面功能类型
if page_type == "GlobalConfiguration":
if element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
SELENIUM_LOG_SCREEN(wd, "50")
elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(2)
\ No newline at end of file
...@@ -23,6 +23,9 @@ class AndroidInformation: ...@@ -23,6 +23,9 @@ 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='安卓信息')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='安卓信息', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,29 +33,32 @@ class AndroidInformation: ...@@ -30,29 +33,32 @@ class AndroidInformation:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "安卓信息")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "AndroidInformation": # 赋值页面类型page
if element_type == "click": page_type = step.get('page')
safe_click((locator_type, locator_value), wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(2) locator_type = get_by_enum(step.get('locator_type'))
elif element_type == "input": # 赋值元素值
safe_send_keys((locator_type, locator_value), element_value, wd) locator_value = step.get('locator_value')
sleep(2) # 赋值元素类型,例如:click点击、input输入框等
elif element_type == "getText": element_type = step.get('element_type')
notify_text = elment_get_text((locator_type,locator_value), wd) # 赋值元素值,例如输入框的输入值
INFO(f"获取的文本为:{notify_text}") element_value = step.get('element_value')
CHECK_POINT("判断当前界面是否正确", expented_result in notify_text) # 赋值预期结果
SELENIUM_LOG_SCREEN(wd, "50") expented_result = step.get('expented_result')
\ No newline at end of file
# 判断页面功能类型
if page_type == "AndroidInformation":
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 == "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")
\ No newline at end of file
...@@ -24,11 +24,11 @@ csv_file_path = os.path.join(current_dir, '../../../测试数据/展厅巡检/ ...@@ -24,11 +24,11 @@ csv_file_path = os.path.join(current_dir, '../../../测试数据/展厅巡检/
# 定义时间格式 # 定义时间格式
time_format = "%H:%M" time_format = "%H:%M"
class Exhibition_hall_inspection_000x: class Exhibition_hall_inspection:
""" """
执行指令: 执行指令:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --test 展厅巡检_0** 2.hytest --report_title 展厅会议预约测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 展厅巡检会议系统
""" """
tags = ['展厅巡检','展厅巡检会议系统'] tags = ['展厅巡检','展厅巡检会议系统']
ddt_cases = read_csv_data(csv_file_path) ddt_cases = read_csv_data(csv_file_path)
...@@ -87,8 +87,8 @@ class Exhibition_hall_inspection_000x: ...@@ -87,8 +87,8 @@ class Exhibition_hall_inspection_000x:
sleep(1) sleep(1)
# 调用函数添加议题 # 调用函数添加议题
# INFO("添加议题文件") INFO("添加议题文件")
# issue_send_and_upload(wd, 5, issue_name) issue_send_and_upload(wd, 5, issue_name)
sleep(2) sleep(2)
# 选择签到时间 # 选择签到时间
......
...@@ -118,9 +118,11 @@ class Exhibition_Meeting_Control_0001: ...@@ -118,9 +118,11 @@ class Exhibition_Meeting_Control_0001:
sleep(1) sleep(1)
safe_send_keys((By.XPATH, "//input[@id='input_checkin']"), "30", wd) safe_send_keys((By.XPATH, "//input[@id='input_checkin']"), "30", wd)
# 根据开始时间选择8点30 # 调用函数根据当前时间进行选择
safe_click((By.XPATH, f"(//div[normalize-space()='08:30'])[1]"), wd) current_time = get_current_time_formatted()
safe_click((By.XPATH, f"(//div[normalize-space()='08:45'])[1]"), wd) INFO(f"获取当前的时间{current_time}")
safe_click((By.XPATH, f"//div[normalize-space()='{current_time}']"), wd)
sleep(1)
# 在会议预定第二步界面进行数据填入 # 在会议预定第二步界面进行数据填入
STEP(4, "会议第二步数据填写") STEP(4, "会议第二步数据填写")
......
...@@ -23,6 +23,9 @@ class TokenManage: ...@@ -23,6 +23,9 @@ 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='授权码管理')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='授权码管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,32 +33,35 @@ class TokenManage: ...@@ -30,32 +33,35 @@ class TokenManage:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "授权码管理")
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
for step in case: page_type = step.get('page')
print(f"当前步骤: {step}") # 赋值元素定位类型,并将字符串转为Enum类型
# 先赋值 locator_type = get_by_enum(step.get('locator_type'))
locator_type = get_by_enum(step.get('locator_type')) # 赋值元素值
locator_value = step.get('locator_value') locator_value = step.get('locator_value')
element_type = step.get('element_type') # 赋值元素类型,例如:click点击、input输入框等
element_value = step.get('element_value') element_type = step.get('element_type')
expented_result = step.get('expented_result') # 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 判断页面功能类型 # 赋值预期结果
if step.get("page") == "TokenManage": expented_result = step.get('expented_result')
if element_type == "click":
safe_click((locator_type, locator_value), wd) # 判断页面功能类型
sleep(2) if page_type == "TokenManage":
if element_type == "click":
elif element_type == "input": safe_click((locator_type, locator_value), wd)
safe_send_keys((locator_type, locator_value), element_value, wd) sleep(2)
send_keyboard((locator_type, locator_value), wd)
sleep(2) elif element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd)
elif element_type == "getText": send_keyboard((locator_type, locator_value), wd)
notify_text = elment_get_text((locator_type, locator_value), wd) sleep(2)
INFO(f"获取到的文本为:{notify_text}")
CHECK_POINT(f"获取到的文本为:{notify_text}", expented_result in notify_text) elif element_type == "getText":
SELENIUM_LOG_SCREEN(wd, "50") notify_text = elment_get_text((locator_type, locator_value), wd)
\ No newline at end of file INFO(f"获取到的文本为:{notify_text}")
CHECK_POINT(f"获取到的文本为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class Login_00x: class Login:
tags = ['新-登录测试'] tags = ['新-登录测试']
""" """
执行指令是: 执行指令是:
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='登录页面')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='登录页面', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,51 +33,51 @@ class Login_00x: ...@@ -30,51 +33,51 @@ class Login_00x:
本函数根据参数输入账号、密码和验证码,并检查登录后的提示信息是否与预期相符。 本函数根据参数输入账号、密码和验证码,并检查登录后的提示信息是否与预期相符。
""" """
wd = GSTORE['wd'] wd = GSTORE['wd']
ddt_cases = read_xlsx_data(xlsx_file_path, "登录页面") name = self.name
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
for step in case: page_type = step.get('page')
print(f"当前步骤: {step}") # 赋值元素定位类型,并将字符串转为Enum类型
# 你可以在这里对 step 进行进一步处理 locator_type = get_by_enum(step.get('locator_type'))
# 例如:访问特定字段 # 赋值元素值
# page = step.get('page') locator_value = step.get('locator_value')
# 调用get_by_enum将定位类型转为枚举 # 赋值元素类型,例如:click点击、input输入框等
locator_type = get_by_enum(step.get('locator_type')) element_type = step.get('element_type')
locator_value = step.get('locator_value') # 赋值元素值,例如输入框的输入值
element_type = step.get('element_type') element_value = step.get('element_value')
element_value = step.get('element_value') # 赋值预期结果
expented_result = step.get('expented_result') expented_result = step.get('expented_result')
if element_type == 'input': if element_type == 'input':
INFO(f"输入值: {element_value}") INFO(f"输入值: {element_value}")
safe_send_keys((locator_type, locator_value), element_value, wd) safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(1) sleep(1)
elif element_type == 'click': elif element_type == 'click':
INFO("点击【登录】按钮") INFO("点击【登录】按钮")
safe_click((locator_type, locator_value), wd) safe_click((locator_type, locator_value), wd)
sleep(2) sleep(2)
if "成功" in expented_result: if "成功" in expented_result:
notify_text = elment_get_text((By.CSS_SELECTOR, "div[class='meeting_t'] span:nth-child(1)"), wd) notify_text = elment_get_text((By.CSS_SELECTOR, "div[class='meeting_t'] span:nth-child(1)"), wd)
SELENIUM_LOG_SCREEN(wd, '50%', 'Login', 'Login_Pwd', "检查登录成功提示信息") SELENIUM_LOG_SCREEN(wd, '50%', 'Login', 'Login_Pwd', "检查登录成功提示信息")
INFO(f"Alert text: {notify_text}") INFO(f"Alert text: {notify_text}")
CHECK_POINT('检查是否出现提示弹窗', "欢迎" in notify_text) CHECK_POINT('检查是否出现提示弹窗', "欢迎" in notify_text)
safe_click((By.XPATH, "//img[@title='退出登录']"), wd) safe_click((By.XPATH, "//img[@title='退出登录']"), wd)
sleep(2) sleep(2)
elif "错误" in expented_result: elif "错误" in expented_result:
notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"), 'Login', notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"), 'Login',
'Login_Pwd', f"检查{expented_result}登录的提示信息") 'Login_Pwd', f"检查{expented_result}登录的提示信息")
INFO(f"获取到的结果:{notify_text}") INFO(f"获取到的结果:{notify_text}")
CHECK_POINT('检查是否出现提示弹窗', expented_result in notify_text) CHECK_POINT('检查是否出现提示弹窗', expented_result in notify_text)
sleep(2) sleep(2)
elif "请输入" in expented_result: elif "请输入" in expented_result:
notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"), 'Login', notify_text = get_notify_text(wd, (By.XPATH, "//p[@class='el-message__content']"), 'Login',
'Login_Pwd', f"检查{expented_result}登录的提示信息") 'Login_Pwd', f"检查{expented_result}登录的提示信息")
INFO(f"获取到的结果:{notify_text}") INFO(f"获取到的结果:{notify_text}")
CHECK_POINT('检查是否出现提示弹窗', expented_result in notify_text) CHECK_POINT('检查是否出现提示弹窗', expented_result in notify_text)
sleep(2) sleep(2)
\ No newline at end of file \ No newline at end of file
...@@ -23,6 +23,9 @@ class SystemManage: ...@@ -23,6 +23,9 @@ 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='系统管理')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='系统管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,33 +33,36 @@ class SystemManage: ...@@ -30,33 +33,36 @@ class SystemManage:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "系统管理")
# 遍历 ddt_cases 并获取每一个 JSON 对象 for step in self.para:
for case in ddt_cases: # 赋值页面类型page
for step in case: page_type = step.get('page')
print(f"当前步骤: {step}") # 赋值元素定位类型,并将字符串转为Enum类型
# 先赋值 locator_type = get_by_enum(step.get('locator_type'))
locator_type = get_by_enum(step.get('locator_type')) # 赋值元素值
locator_value = step.get('locator_value') locator_value = step.get('locator_value')
element_type = step.get('element_type') # 赋值元素类型,例如:click点击、input输入框等
element_value = step.get('element_value') element_type = step.get('element_type')
expented_result = step.get('expented_result') # 赋值元素值,例如输入框的输入值
element_value = step.get('element_value')
# 判断页面功能类型 # 赋值预期结果
if step.get("page") == "SystemLog": expented_result = step.get('expented_result')
# 判断page为系统日志界面,点击【系统日志】,进入系统日志模块
safe_click((By.XPATH, "//li[contains(text(),'系统日志')]"), wd) # 判断页面功能类型
sleep(1) if page_type == "SystemLog":
# 判断page为系统日志界面,点击【系统日志】,进入系统日志模块
if element_type == "click": safe_click((By.XPATH, "//li[contains(text(),'系统日志')]"), wd)
safe_click((locator_type, locator_value), wd) sleep(1)
sleep(2)
elif element_type == "input": if element_type == "click":
safe_send_keys((locator_type, locator_value), element_value, wd) safe_click((locator_type, locator_value), wd)
sleep(2) sleep(2)
elif element_type == "getText": elif element_type == "input":
notify_text = elment_get_text((locator_type,locator_value), wd) safe_send_keys((locator_type, locator_value), element_value, wd)
INFO(f"获取的文本为:{notify_text}") sleep(2)
CHECK_POINT("判断当前界面是否正确", expented_result in notify_text) elif element_type == "getText":
SELENIUM_LOG_SCREEN(wd, "50") notify_text = elment_get_text((locator_type, locator_value), wd)
\ No newline at end of file INFO(f"获取的文本为:{notify_text}")
CHECK_POINT("判断当前界面是否正确", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) ...@@ -16,13 +16,16 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径 # 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx') xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class ConferenceStatistics: class AccountManagement:
tags = ['新-账号管理测试', 'JSON测试'] tags = ['新-账号管理测试', 'JSON测试']
""" """
执行指令是: 执行指令是:
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='账号管理')
# 测试开始前调用clear_columns_in_xlsx函数,将测试用例中的测试结果和日志截图置空
clear_columns_in_xlsx(xlsx_file_path, sheet_name='账号管理', columns_to_clear=['测试结果', '测试频次', '日志截图'])
def teststeps(self): def teststeps(self):
""" """
...@@ -30,29 +33,32 @@ class ConferenceStatistics: ...@@ -30,29 +33,32 @@ class ConferenceStatistics:
""" """
# 从全局存储中获取webdriver对象 # 从全局存储中获取webdriver对象
wd = GSTORE['wd'] wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据 name = self.name
ddt_cases = read_xlsx_data(xlsx_file_path, "账号管理")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
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')
# 判断页面功能类型 for step in self.para:
if step.get("page") == "CompanyManagement": # 赋值页面类型page
if element_type == "click": page_type = step.get('page')
safe_click((locator_type, locator_value), wd) # 赋值元素定位类型,并将字符串转为Enum类型
sleep(2) locator_type = get_by_enum(step.get('locator_type'))
elif element_type == "input": # 赋值元素值
safe_send_keys((locator_type, locator_value), element_value, wd) locator_value = step.get('locator_value')
sleep(2) # 赋值元素类型,例如:click点击、input输入框等
elif element_type == "getTips": element_type = step.get('element_type')
notify_text = get_notify_text(wd, (locator_type, locator_value)) # 赋值元素值,例如输入框的输入值
INFO(f"获取到的提示信息为:{notify_text}") element_value = step.get('element_value')
CHECK_POINT(f"获取到的提示信息为:{notify_text}", expented_result in notify_text) # 赋值预期结果
SELENIUM_LOG_SCREEN(wd, "50") expented_result = step.get('expented_result')
\ No newline at end of file
# 判断页面功能类型
if page_type == "CompanyManagement":
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}")
CHECK_POINT(f"获取到的提示信息为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "50")
\ No newline at end of file
...@@ -20,7 +20,6 @@ class ChangAnMessageApproval: ...@@ -20,7 +20,6 @@ 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='会议审批')
# 测试开始前调用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=['测试结果', '测试频次', '日志截图'])
...@@ -36,6 +35,8 @@ class ChangAnMessageApproval: ...@@ -36,6 +35,8 @@ class ChangAnMessageApproval:
meeting_message("审批会议室", "普通会议", "审批测试会议", "长安大学", wd) meeting_message("审批会议室", "普通会议", "审批测试会议", "长安大学", wd)
for step in self.para: for step in self.para:
# 赋值页面类型page
page_type = step.get('page')
# 赋值元素定位类型,并将字符串转为Enum类型 # 赋值元素定位类型,并将字符串转为Enum类型
locator_type = get_by_enum(step.get('locator_type')) locator_type = get_by_enum(step.get('locator_type'))
# 赋值元素值 # 赋值元素值
...@@ -48,7 +49,7 @@ class ChangAnMessageApproval: ...@@ -48,7 +49,7 @@ class ChangAnMessageApproval:
expented_result = step.get('expented_result') expented_result = step.get('expented_result')
# 判断页面功能类型 # 判断页面功能类型
if step.get("page") == "ApprovalInitiate": if page_type == "ApprovalInitiate":
if element_type == "input": if element_type == "input":
safe_send_keys((locator_type, locator_value), element_value, wd) safe_send_keys((locator_type, locator_value), element_value, wd)
......
name,conference_name,message_name,book_type,issue_name,book_start_time,book_end_time,message_notification,check_text name,conference_name,message_name,book_type,issue_name,book_start_time,book_end_time,message_notification,check_text
展厅巡检_001,MeetingRoom,展厅巡检测试,普通会议,议题1,08:00,08:15,开会前一天提醒,预定成功 展厅巡检_001,展厅会议室,展厅巡检测试,普通会议,议题1,08:00,08:15,开会前一天提醒,预定成功
\ No newline at end of file \ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论