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

refactor(预定系统):

- 更新展厅巡检结尾步骤,增加腾讯会议、讯飞转录以及SMC选项
上级 34f8058a
......@@ -329,3 +329,5 @@
- read_xlsx_data函数优化,调试兰州中石化项目自动化测试。
97. 2025-07-01:
- feat(预定系统): 更新脚本支持多环境配置,新增 JSON 配置文件,支持不同环境的配置,重构代码,实现环境配置的动态加载- 添加命令行参数,允许选择更新环境,优化日志输出,提高错误处理能力。
98. 2025-08-20:
- 更新展厅巡检结尾步骤,增加腾讯会议、讯飞转录以及SMC选项。
\ No newline at end of file
......@@ -28,53 +28,53 @@ class ExhibitionMeetingControl:
执行测试步骤以自动化测试腾讯会议应用的登录和会议加入流程。
该方法初始化应用驱动,等待应用加载,定位并点击会议按钮,加入会议,并截取会议画面。
"""
app_drive = None
try:
# 初始化应用驱动,连接到指定的设备和应用
app_drive = app_setup_driver("Android", "5.1.1", "UT-12", "com.ubains.gviewer.develop",
"com.ubains.gviewer.activity.SplashActivity", "192.168.5.142:5555")
app_drive.implicitly_wait(60) # 设置缺省等待时间
logging.info("等待登录页加载...")
sleep(20)
# 点击左上角logo进入后台
enter_back_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.Button[1]")
logging.info("点击左上角logo进入后台")
enter_back_button.click()
sleep(10)
# 点击【系统关】按钮
system_off_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[2]/android.widget.Button[9]")
logging.info("点击【系统关】按钮")
system_off_button.click()
sleep(10)
# 点击【主页】按钮
home_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[2]/android.widget.Button[1]")
logging.info("点击【主页】按钮,返回主页界面")
home_button.click()
sleep(10)
# 点击【离开模式】按钮
quit_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[3]/android.widget.Button[15]")
logging.info("点击【离开模式】按钮")
quit_button.click()
sleep(10)
# 点击【确定】按钮
safe_click_button = app_drive.find_element(AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[4]/android.widget.Button[1]")
logging.info("点击【确定】按钮,展厅会议室环境设备已断电。")
safe_click_button.click()
sleep(10)
except Exception as e:
# 捕获并记录任何发生的错误
logging.error(f"发生错误: {e}", exc_info=True)
# app_drive = None
# try:
# # 初始化应用驱动,连接到指定的设备和应用
# app_drive = app_setup_driver("Android", "5.1.1", "UT-12", "com.ubains.gviewer.develop",
# "com.ubains.gviewer.activity.SplashActivity", "192.168.5.142:5555")
# app_drive.implicitly_wait(60) # 设置缺省等待时间
# logging.info("等待登录页加载...")
# sleep(20)
#
# # 点击左上角logo进入后台
# enter_back_button = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.Button[1]")
# logging.info("点击左上角logo进入后台")
# enter_back_button.click()
# sleep(10)
#
# # 点击【系统关】按钮
# system_off_button = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[2]/android.widget.Button[9]")
# logging.info("点击【系统关】按钮")
# system_off_button.click()
# sleep(10)
#
# # 点击【主页】按钮
# home_button = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[2]/android.widget.Button[1]")
# logging.info("点击【主页】按钮,返回主页界面")
# home_button.click()
# sleep(10)
#
# # 点击【离开模式】按钮
# quit_button = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[3]/android.widget.Button[15]")
# logging.info("点击【离开模式】按钮")
# quit_button.click()
# sleep(10)
#
# # 点击【确定】按钮
# safe_click_button = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout[4]/android.widget.Button[1]")
# logging.info("点击【确定】按钮,展厅会议室环境设备已断电。")
# safe_click_button.click()
# sleep(10)
#
# except Exception as e:
# # 捕获并记录任何发生的错误
# logging.error(f"发生错误: {e}", exc_info=True)
# 补充预定系统会议创建
# 初始化通知文本为空字符串
......@@ -102,20 +102,22 @@ class ExhibitionMeetingControl:
# 在会议预定第一步界面进行数据填入
STEP(3, "会议第一步数据填写")
INFO(
f"输入会议名称:{message_name},选择会议类型:视讯融合会议,选择预约类型:{book_type}")
f"输入会议名称:{message_name},选择会议类型:视讯融合会议,SMC3.0视频会议,腾讯会议,选择预约类型:{book_type}")
# 输入会议名称
safe_send_keys((By.XPATH, "//input[@placeholder='请输入会议名称']"), message_name, wd)
# 判断会议类型
safe_click((By.XPATH,
"//div[@class='reserve_input']//span[@class='el-checkbox__label'][normalize-space()='SMC3.0视频会议']"),
wd)
safe_click((By.XPATH,
f"//div[@class='reserve_input']//span[@class='el-checkbox__label'][normalize-space()='讯飞语音转录']"),
wd)
safe_click((By.XPATH,
f"//div[@class='reserve_input']//span[@class='el-checkbox__label'][normalize-space()='腾讯会议']"),
wd)
sleep(2)
# 选择普通会议
safe_click((By.XPATH, f"//span[contains(text(),'{book_type}')]"), wd)
sleep(1)
# 选择签到时间
INFO("选择提前30分钟开始签到")
safe_click((By.XPATH, "(//span[@class='el-switch__core'])[2]"), wd)
......@@ -127,6 +129,9 @@ class ExhibitionMeetingControl:
current_time = get_current_time_formatted()
INFO(f"获取当前的时间{current_time}")
safe_click((By.XPATH, f"//div[normalize-space()='{current_time}']"), wd)
sleep(2)
# 选择会议结束时间
safe_click((By.XPATH, "//div[normalize-space()='09:00']"), wd)
sleep(1)
# 在会议预定第二步界面进行数据填入
......
......@@ -49,103 +49,28 @@ class Login:
safe_send_keys((locator_type, locator_value), element_value, wd)
sleep(1)
elif element_type == 'click':
INFO("点击【登录】按钮")
elif element_type == "click":
safe_click((locator_type, locator_value), wd)
sleep(2)
if "成功" in expected_result:
# 获取登录成功提示信息
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', "检查登录成功提示信息")
# 记录提示信息
INFO(f"Alert text: {notify_text}")
CHECK_POINT('检查是否出现提示弹窗', "欢迎" in notify_text)
# 检查提示信息是否包含“欢迎”
# if CHECK_POINT('检查是否出现提示弹窗', "欢迎" in notify_text):
# # 如果提示信息不正确,记录为失败
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"失败,提示{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
# else:
# # 如果提示信息正确,记录为成功
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"成功,正确提示:{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
# 点击退出登录按钮
safe_click((By.XPATH, "//img[@title='退出登录']"), wd)
sleep(2)
SELENIUM_LOG_SCREEN(wd, "75")
elif "错误" in expected_result:
# 获取登录错误提示信息
notify_text = get_notify_text(
wd,
(By.XPATH, "//p[@class='el-message__content']"),
'Login',
'Login_Pwd',
f"检查{expected_result}登录的提示信息"
)
# 记录获取到的结果
INFO(f"获取到的结果:{notify_text}")
CHECK_POINT('检查是否出现提示弹窗', expected_result in notify_text)
# 检查提示信息是否包含预期的错误信息
# if CHECK_POINT('检查是否出现提示弹窗', expected_result in notify_text):
# # 如果提示信息不正确,记录为失败
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"失败,提示:{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
# else:
# # 如果提示信息正确,记录为成功
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"成功,正确提示:{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
elif element_type == "login":
# 退出系统登录
safe_click((By.XPATH, "//div[@class='quit']"), wd)
sleep(2)
INFO(f"开始登录,账号为:{element_value[0]},密码为:{element_value[1]}")
user_login(element_value[0],element_value[1])
sleep(2)
elif "请输入" in expected_result:
# 获取登录提示信息
notify_text = get_notify_text(
wd,
(By.XPATH, "//p[@class='el-message__content']"),
'Login',
'Login_Pwd',
f"检查{expected_result}登录的提示信息"
)
# 记录获取到的结果
INFO(f"获取到的结果:{notify_text}")
CHECK_POINT('检查是否出现提示弹窗', expected_result in notify_text)
# 检查提示信息是否包含预期的提示信息
# if CHECK_POINT('检查是否出现提示弹窗', expected_result in notify_text):
# # 如果提示信息不正确,记录为失败
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"失败,提示:{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
# else:
# # 如果提示信息正确,记录为成功
# write_xlsx_data(
# xlsx_file_path,
# "登录页面",
# name,
# f"成功,正确提示:{notify_text}",
# r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Login\Login_Pwd\检查登录成功提示信息.png"
# )
elif element_type == "getTips":
notify_text = get_notify_text(wd, (locator_type, locator_value))
INFO(f"获取到的提示信息为:{notify_text}")
sleep(2)
CHECK_POINT(f"获取到的提示信息为:{notify_text}", expected_result in notify_text)
SELENIUM_LOG_SCREEN(wd, "75")
elif element_type == "getText":
text = elment_get_text((locator_type, locator_value), wd)
INFO(f"获取到的文本信息为:{text}")
CHECK_POINT(f"获取到的文本信息为:{text}", expected_result in text)
SELENIUM_LOG_SCREEN(wd, "75")
\ No newline at end of file
......@@ -3,7 +3,7 @@ import os
from hytest import *
# 获取 Base 目录的绝对路径,并加入 sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..' , '..')))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')))
from 预定系统.Base.base import *
def suite_setup():
......
......@@ -2,14 +2,14 @@ import sys
import os
# 获取 Base 目录的绝对路径,并加入 sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..' , '..')))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..')))
from 预定系统.Base.base import *
# 构建XLSX文件的绝对路径
# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
xlsx_file_path = os.path.join(current_dir, '..', '..', '..', '..', '测试数据', '会议预定测试用例.xlsx')
# xlsx_file_path = os.path.join(预定系统_path, '测试数据', '长安大学测试用例.xlsx')
# 获取当前脚本所在的目录
xlsx_file_path = os.path.join(current_dir, '..', '..', '..', '测试数据', '会议预定测试用例.xlsx')
# xlsx_file_path = os.path.join(预定系统_path, '测试数据', '兰州中石化项目测试用例.xlsx')
class ChangAnMessageApproval:
tags = ['长安大学取消审批测试']
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论