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

封装会议创建、结束会议与会议状态操作的公用方法,通过会议室名称与会议类型来做判断,减少代码冗杂。实现测试用例中会议创建的部分功能。

上级 7aa6daaa
......@@ -1463,3 +1463,139 @@ def get_current_time_formatted():
closest_time_point = time_points[0]
return closest_time_point
# 会议创建函数
def meeting_message(meeting_room_name, message_type, wd):
"""
会议室会议预定功能的实现。
该函数通过模拟用户交互来预定会议室会议。它首先搜索指定的会议室,然后填写会议信息,
包括会议名称和类型,最后选择会议时间并完成预定。
参数:
- MeetingRoomName (str): 会议室名称,用于搜索指定的会议室。
- MessageType (str): 会议类型,用于填写会议信息。
- wd: WebDriver实例,用于操作浏览器。
返回:
无返回值。
"""
# 先搜索会议室
safe_click((By.XPATH, "//i[@class='el-collapse-item__arrow el-icon-arrow-right']"), wd)
sleep(1)
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议室名称']"), meeting_room_name, wd)
INFO(f"搜索结果为:{meeting_room_name}")
# 点击【查询】按钮
safe_click((By.XPATH, "//span[contains(text(),'查询')]"), wd)
sleep(2)
# 点击【会议预定】按钮
safe_click((By.XPATH, "//span[@class='MeetingCityList_t_btn']"), wd)
sleep(2)
# 输入会议名称并勾选MessageType类型
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议名称']"), message_type, wd)
safe_click(
(By.XPATH, f"//div[@class='reserve_input']//span[@class='el-checkbox__label'][contains(text(),'{message_type}')]"), wd)
sleep(1)
# 选择会议时间,点击【快速预定】按钮
current_time = get_current_time_formatted()
print(f"获取当前的时间{current_time}")
safe_click((By.XPATH, f"//div[normalize-space()='{current_time}']"), wd)
sleep(1)
safe_click((By.XPATH, "//div[@class='header_Quick']"), wd)
safe_click((By.XPATH, "//div[@class='header_Quick']"), wd)
sleep(2)
# 点击【确定】按钮
safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'预定')]"), wd)
sleep(2)
# 会议状态设置函数
def message_satus_control(message_name, message_type, control_type, wd):
"""
结束会议流程。
参数:
- message_name: 会议名称,用于搜索特定的会议。
- message_type: 会议类型,用于判断是否需要进行额外的确认操作。
- control_type: 控制类型,用于选择相应的会议控制操作。
- wd: WebDriver实例,用于操作浏览器。
该函数通过模拟用户交互来结束会议,包括搜索会议、点击相关按钮等操作。
"""
# 输入会议名称并搜索
safe_send_keys((By.XPATH, "//input[@placeholder='输入关键字搜索']"), message_name, wd)
send_keyboard((By.XPATH, "//input[@placeholder='输入关键字搜索']"), 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, f"//span[contains(text(),'{control_type}')]"), wd)
sleep(1)
safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd)
sleep(2)
# 针对特定会议平台的额外确认操作
if message_type == "会控":
safe_click((By.XPATH,
"//button[@class='el-button el-button--default el-button--small el-button--primary ']//span[contains(text(),'确定')]"),
wd)
sleep(1)
# 进入会议预约界面函数
def enter_meeting_booking_page(meeting_room_name, wd):
"""
进入会议室预订页面并填写会议信息。
:param meeting_room_name: 会议室名称,用于搜索特定的会议室。
:param wd: WebDriver实例,用于操作浏览器。
"""
# 先搜索会议室
safe_click((By.XPATH, "//i[@class='el-collapse-item__arrow el-icon-arrow-right']"), wd)
sleep(1)
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议室名称']"), meeting_room_name, wd)
INFO(f"搜索结果为:{meeting_room_name}")
# 点击【查询】按钮
safe_click((By.XPATH, "//span[contains(text(),'查询')]"), wd)
sleep(2)
# 点击【会议预定】按钮
safe_click((By.XPATH, "//span[@class='MeetingCityList_t_btn']"), wd)
sleep(2)
# 输入会议名称并勾选MessageType类型
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议名称']"), "测试", wd)
sleep(1)
# 选择会议时间
current_time = get_current_time_formatted()
print(f"获取当前的时间{current_time}")
safe_click((By.XPATH, f"//div[normalize-space()='{current_time}']"), wd)
sleep(1)
# 删除会议函数
def del_message(message_name, wd):
"""
删除会议消息。
根据会议名称搜索并删除会议。
参数:
- message_name: 会议名称,用于搜索特定的会议。
- wd: WebDriver实例,用于执行网页自动化操作。
此函数无返回值。
"""
# 输入会议名称并搜索
safe_send_keys((By.XPATH, "//input[@placeholder='输入关键字搜索']"), message_name, wd)
send_keyboard((By.XPATH, "//input[@placeholder='输入关键字搜索']"), wd)
sleep(2)
# 点击【删除会议】按钮
safe_click((By.XPATH, "//span[contains(text(),'删除会议')]"), wd)
sleep(2)
# 点击【确定】按钮
safe_click((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确定')]"), wd)
sleep(1)
# 进入【会议室列表】界面
safe_click((By.XPATH, "//span[contains(text(),'会议室列表')]"), wd)
sleep(1)
\ No newline at end of file
......@@ -243,6 +243,8 @@
- Base函数库中的函数缩略补充函数使用说明,增加相关注释,删除无用函数。
64. 2025-03-07
- 删除中控屏操作的多余截屏函数调用。处理get_screenshot_with_retry函数的目录构建传参问题。
65. 2025-03-1-
65. 2025-03-10
- 处理read_xlsx_data函数增加sheet传参,实现测试用例中会议室列表的部分功能。
- 封装获取当前会议时间转换格式函数,用于所有的会议预定功能测试使用。实现测试用例中会控-SMC的部分功能。
\ No newline at end of file
- 封装获取当前会议时间转换格式函数,用于所有的会议预定功能测试使用。实现测试用例中会控-SMC的部分功能。
66. 2025-03-11
- 实现测试用例中会控-腾讯会议的部分功能。封装会议创建、结束会议与会议状态操作的公用方法,通过会议室名称与会议类型来做判断,减少代码冗杂。实现测试用例中会议创建的部分功能。
\ No newline at end of file
......@@ -16,12 +16,12 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class Login_00x:
class SMCMeeting_00x:
tags = ['新-会控SMC测试']
"""
执行指令是:
1.cd 预定系统
2.hytest --report_title 账号密码登录测试报告 --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测试
"""
def teststeps(self):
......@@ -30,6 +30,9 @@ class Login_00x:
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
# 调用会议创建函数
meeting_message("SMC会议室", "SMC3.0", wd)
sleep(1)
for step in case:
print(f"当前步骤: {step}")
# 先赋值
......@@ -38,6 +41,8 @@ class Login_00x:
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_SMC":
......@@ -61,4 +66,10 @@ class Login_00x:
notify_text = elment_get_text((By.XPATH, "//div[@id='tab-smcList']"), wd)
INFO(f"当前页面标题为:{notify_text}")
CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "SMC会控")
\ No newline at end of file
SELENIUM_LOG_SCREEN(wd, "SMC会控")
# 切换窗口
wd.switch_to.window(wd.window_handles[0])
wd.refresh()
# 调用会议结束函数,传入会议名称
INFO(f"调用end_the_meeting函数结束{message_name}名称的会议")
message_satus_control(message_name, "会控", "结束会议",wd)
\ No newline at end of file
......@@ -15,57 +15,8 @@ def suite_setup():
# 初始化浏览器与系统地址
browser_init("标准版预定系统")
admin_login("admin@Test", "Ubains@4321")
wd = GSTORE['wd']
sleep(2)
# 先创建SMC会议
STEP(1, "搜索会议室")
safe_click((By.XPATH, "//i[@class='el-collapse-item__arrow el-icon-arrow-right']"), wd)
sleep(1)
# 搜索SMC会议室
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议室名称']"), "SMC会议室", wd)
send_keyboard((By.XPATH, "//input[@placeholder='请输入会议室名称']"), wd)
sleep(2)
# 点击【查询】按钮
safe_click((By.XPATH, "//span[contains(text(),'查询')]"), wd)
# 点击【会议预定】按钮
safe_click((By.XPATH, "//span[@class='MeetingCityList_t_btn']"), wd)
sleep(2)
# 输入会议名称并勾选SMC会议类型
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议名称']"), "SMC会议", wd)
safe_click(
(By.XPATH, "//div[@class='reserve_input']//span[@class='el-checkbox__label'][normalize-space()='SMC3.0']"), wd)
sleep(1)
# 选择会议时间,点击【快速预定】按钮
current_time = get_current_time_formatted()
print(f"获取当前的时间{current_time}")
safe_click((By.XPATH, f"//div[normalize-space()='{current_time}']"), wd)
sleep(1)
safe_click((By.XPATH, "//div[@class='header_Quick']"), wd)
safe_click((By.XPATH, "//div[@class='header_Quick']"), wd)
sleep(2)
# 点击【确定】按钮
safe_click((By.XPATH, "//button[@type='button']//span[contains(text(),'预定')]"), wd)
sleep(2)
def suite_teardown():
wd = GSTORE['wd']
# 切换窗口
wd.switch_to.window(wd.window_handles[0])
wd.refresh()
safe_send_keys((By.XPATH, "//input[@placeholder='输入关键字搜索']"), "SMC会议", wd)
send_keyboard((By.XPATH, "//input[@placeholder='输入关键字搜索']"), 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, "//span[contains(text(),'提前结束')]"), wd)
sleep(1)
safe_click((By.XPATH, "//div[@slot='footer']//span[contains(text(),'确定')]"), wd)
sleep(2)
safe_click((By.XPATH, "//button[@class='el-button el-button--default el-button--small el-button--primary ']//span[contains(text(),'确定')]"), wd)
sleep(1)
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 *
def suite_setup():
STEP(1, "初始化浏览器")
# 初始化浏览器与系统地址
browser_init("标准版预定系统")
admin_login("admin@Test", "Ubains@4321")
sleep(2)
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 *
# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class TxcentMeeting_00x:
tags = ['新-会控腾讯测试']
"""
执行指令是:
1.cd 预定系统
2.hytest --report_title 腾讯会控测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会控腾讯测试
"""
def teststeps(self):
"""
执行测试步骤函数,主要用于执行读取的测试用例并进行会议控制操作
"""
# 从全局存储中获取webdriver对象
wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据
ddt_cases = read_xlsx_data(xlsx_file_path, "会控-腾讯会议")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
# 调用会议创建函数
meeting_message("腾讯会议室", "腾讯会议", wd)
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":
if element_type == "input":
# 查询会议
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":
safe_click((locator_type, locator_value), wd)
sleep(2)
# 切换到新窗口
wd.switch_to.window(wd.window_handles[1])
notify_text = elment_get_text((By.XPATH, "//div[@id='tab-Tencent']"), wd)
INFO(f"当前页面标题为:{notify_text}")
CHECK_POINT(f"当前页面标题为:{notify_text}", expented_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "腾讯会控界面")
# 切换窗口
wd.switch_to.window(wd.window_handles[0])
wd.refresh()
# 调用会议结束函数,传入会议名称
INFO(f"调用end_the_meeting函数结束{message_name}名称的会议")
message_satus_control(message_name, "会控", "结束会议",wd)
\ 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("标准版预定系统")
admin_login("admin@Test", "Ubains@4321")
sleep(2)
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 *
# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建XLSX文件的绝对路径
xlsx_file_path = os.path.join(current_dir, '..', '..', '测试数据', '会议预定测试用例.xlsx')
class MeetingMessage_00x:
tags = ['新-会议创建测试']
"""
执行指令是:
1.cd 预定系统
2.hytest --report_title 会议创建测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 新-会议创建测试
"""
def teststeps(self):
"""
执行测试步骤函数,主要用于执行读取的测试用例并进行会议预定界面操作
"""
# 从全局存储中获取webdriver对象
wd = GSTORE['wd']
# 读取Excel文件中的测试用例数据
ddt_cases = read_xlsx_data(xlsx_file_path, "会议创建")
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
# 调用进入会议预定界面函数
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
# 判断页面功能类型
if step.get("page") == "MessageNameTest":
# 这是会议名称字符测试用例
if element_type == "input":
if expented_result is "":
# 输入会议名称
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(1)
elif expented_result is not "":
# 搜索会议数据,获取会议列表的会议名称
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)
# 调用会议删除函数
INFO("调用会议删除函数")
del_message(message_name, wd)
elif element_type == "click":
# 点击快速预定按钮
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)
\ No newline at end of file
......@@ -50,7 +50,7 @@ class Unified_Platform_0001:
safe_click((By.XPATH, "//span[contains(text(),'完成')]"),wd)
sleep(2)
# 创建会议,并查看详情
# 会议创建,并查看详情
safe_click((By.XPATH, "//span[contains(text(),'确定创建')]"),wd)
sleep(8)
# 存在视讯资源不足提示,继续点击【确定】按钮
......
topic,action,thirdPartyMeetingId,thirdPartyRoomId,conferenceName,messageName,startTime,endTime,companyNumber
/meeting/message/sync,add,7565416702283087898,1,表处办公室1号会议室,富创预约,2025-03-09 16:31:00.0,2025-03-09 16:43:00.0,CN-JHP-UBAINS
\ No newline at end of file
/meeting/message/sync,add,7565416702283087899,1,表处办公室1号会议室,富创预约,2025-03-11 16:11:00.0,2025-03-11 16:23:00.0,CN-JHP-UBAINS
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论