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

缩短元素等待时间,调整展厅巡检视讯会议的会控按钮判断。增加议题文件上传未完成时点击【确定】弹出的确认框补充点击确认操作。

上级 6d5450e7
...@@ -17,6 +17,9 @@ from selenium.common import ElementNotInteractableException ...@@ -17,6 +17,9 @@ from selenium.common import ElementNotInteractableException
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from urllib.parse import urlencode from urllib.parse import urlencode
from datetime import datetime from datetime import datetime
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
# import datetime # import datetime
...@@ -212,7 +215,7 @@ def safe_send_keys(element_locator, value, wd): ...@@ -212,7 +215,7 @@ def safe_send_keys(element_locator, value, wd):
""" """
try: try:
# 等待元素在指定时间内可见 # 等待元素在指定时间内可见
element = WebDriverWait(wd, 60).until(EC.visibility_of_element_located(element_locator)) element = WebDriverWait(wd, 20).until(EC.visibility_of_element_located(element_locator))
element.clear() # 清除元素的当前值 element.clear() # 清除元素的当前值
element.send_keys(value) # 向元素发送指定的键值 element.send_keys(value) # 向元素发送指定的键值
except TimeoutException: except TimeoutException:
...@@ -239,7 +242,7 @@ def safe_click(element_locator, wd): ...@@ -239,7 +242,7 @@ def safe_click(element_locator, wd):
""" """
try: try:
# Wait up to 20 seconds for the element to be visible # Wait up to 20 seconds for the element to be visible
element = WebDriverWait(wd, 60).until(EC.visibility_of_element_located(element_locator)) element = WebDriverWait(wd, 20).until(EC.visibility_of_element_located(element_locator))
# Attempt to click the element # Attempt to click the element
element.click() element.click()
except TimeoutException: except TimeoutException:
...@@ -299,7 +302,13 @@ def issue_send_and_upload(wd, issue_num, issue_name): ...@@ -299,7 +302,13 @@ def issue_send_and_upload(wd, issue_num, issue_name):
upload_button.send_keys(issue_file_path[i]) upload_button.send_keys(issue_file_path[i])
# 等待文件上传完成 # 等待文件上传完成
sleep(15) sleep(15)
confirmbutton = ""
confirmbutton = WebDriverWait(wd, 10).until(
EC.visibility_of_element_located((By.XPATH, "//button[contains(@class,'el-button el-button--default el-button--small el-button--primary')]//span[contains(text(),'确定')]"))
)
if confirmbutton is not None:
confirmbutton.click()
else:
# 截取上传完成后的屏幕日志 # 截取上传完成后的屏幕日志
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Meeting_Message", "添加议题文件") SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Meeting_Message", "添加议题文件")
...@@ -309,6 +318,7 @@ def issue_send_and_upload(wd, issue_num, issue_name): ...@@ -309,6 +318,7 @@ def issue_send_and_upload(wd, issue_num, issue_name):
wd) wd)
sleep(2) sleep(2)
# 清除输入框函数 # 清除输入框函数
def input_clear(element_locator, wd): def input_clear(element_locator, wd):
""" """
...@@ -327,7 +337,7 @@ def input_clear(element_locator, wd): ...@@ -327,7 +337,7 @@ def input_clear(element_locator, wd):
""" """
try: try:
# 等待元素可见,并在可见后清空输入框。 # 等待元素可见,并在可见后清空输入框。
input_element = WebDriverWait(wd, 60).until(EC.visibility_of_element_located(element_locator)) input_element = WebDriverWait(wd, 20).until(EC.visibility_of_element_located(element_locator))
input_element.clear() input_element.clear()
except TimeoutException: except TimeoutException:
# 如果元素在20秒内不可见,打印超时异常消息。 # 如果元素在20秒内不可见,打印超时异常消息。
...@@ -358,7 +368,7 @@ def send_keyboard(element_locator, wd): ...@@ -358,7 +368,7 @@ def send_keyboard(element_locator, wd):
""" """
try: try:
# 等待元素可见,并在可见后向其发送RETURN键点击事件。 # 等待元素可见,并在可见后向其发送RETURN键点击事件。
element = WebDriverWait(wd, 60).until(EC.visibility_of_element_located(element_locator)) element = WebDriverWait(wd, 20).until(EC.visibility_of_element_located(element_locator))
element.send_keys(Keys.RETURN) element.send_keys(Keys.RETURN)
except TimeoutException: except TimeoutException:
# 如果元素在指定时间内不可见,打印超时错误消息。 # 如果元素在指定时间内不可见,打印超时错误消息。
...@@ -390,7 +400,7 @@ def get_notify_text(wd,element_locator,module_name = None,function_name = None,f ...@@ -390,7 +400,7 @@ def get_notify_text(wd,element_locator,module_name = None,function_name = None,f
""" """
try: try:
# 使用WebDriverWait等待元素出现,并获取其文本内容 # 使用WebDriverWait等待元素出现,并获取其文本内容
notify_text = WebDriverWait(wd, 60).until( notify_text = WebDriverWait(wd, 20).until(
EC.presence_of_element_located(element_locator) EC.presence_of_element_located(element_locator)
).text ).text
if module_name or function_name or file_name: if module_name or function_name or file_name:
...@@ -421,7 +431,7 @@ def elment_get_text(element_locator, wd): ...@@ -421,7 +431,7 @@ def elment_get_text(element_locator, wd):
""" """
try: try:
# 使用WebDriverWait等待页面元素在20秒内可见,并获取其文本。 # 使用WebDriverWait等待页面元素在20秒内可见,并获取其文本。
element_text = WebDriverWait(wd, 60).until(EC.visibility_of_element_located(element_locator)).text element_text = WebDriverWait(wd, 20).until(EC.visibility_of_element_located(element_locator)).text
return element_text return element_text
except TimeoutException: except TimeoutException:
# 如果超过20秒元素仍未可见,则捕获TimeoutException异常并打印错误信息。 # 如果超过20秒元素仍未可见,则捕获TimeoutException异常并打印错误信息。
......
...@@ -277,3 +277,5 @@ ...@@ -277,3 +277,5 @@
75. 2025-04-02 75. 2025-04-02
- 将ngrok.cfg配置文件本机IP改为127.0.0.1,避免本机IP变化后无法打开测试报告。 - 将ngrok.cfg配置文件本机IP改为127.0.0.1,避免本机IP变化后无法打开测试报告。
- 处理工商银行JSON数据格式错误问题,处理优化。 - 处理工商银行JSON数据格式错误问题,处理优化。
76. 2025-04-08
- 缩短元素等待时间,调整展厅巡检视讯会议的会控按钮判断。增加议题文件上传未完成时点击【确定】弹出的确认框补充点击确认操作。
\ No newline at end of file
...@@ -193,7 +193,17 @@ class Exhibition_hall_inspection: ...@@ -193,7 +193,17 @@ class Exhibition_hall_inspection:
# 判断是否存在会控按钮 # 判断是否存在会控按钮
INFO("判断是否存在【进入会控】按钮") INFO("判断是否存在【进入会控】按钮")
safe_click((By.XPATH,"//span[contains(text(),'进入会控')]"),wd) MeetingControlButton = ""
MeetingControlButton = WebDriverWait(wd, 10).until(
EC.visibility_of_element_located((By.XPATH, "//span[contains(text(),'进入会控')]"))
)
if MeetingControlButton is not None:
INFO("存在【进入会控】按钮")
CHECK_POINT("检查是否存在【进入会控】按钮", True)
MeetingControlButton.click()
else:
INFO("不存在【进入会控】按钮")
CHECK_POINT("检查是否存在【进入会控】按钮", False)
sleep(5) sleep(5)
# 切换窗口2,转到会控界面 # 切换窗口2,转到会控界面
......
...@@ -5,20 +5,22 @@ from 预定系统.Base.base import * ...@@ -5,20 +5,22 @@ from 预定系统.Base.base import *
current_dir = os.path.dirname(os.path.abspath(__file__)) current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建会议预约CSV文件的绝对路径 # 构建会议预约CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/MQTT模块/富创项目/富创项目_会议预约推送.csv') # csv_file_path = os.path.join(current_dir, '../../../测试数据/MQTT模块/富创项目/富创项目_会议预约推送.csv')
# 构建会议修改CSV文件的绝对路径 # 构建会议修改CSV文件的绝对路径
# csv_file_path = os.path.join(current_dir, '../../测试数据/MQTT模块/富创项目/富创项目_会议修改推送.csv') # csv_file_path = os.path.join(current_dir, '../../../测试数据/MQTT模块/富创项目/富创项目_会议修改推送.csv')
# # 构建会议删除CSV文件的绝对路径 # # 构建会议删除CSV文件的绝对路径
# csv_file_path = os.path.join(current_dir, '../../测试数据/MQTT模块/富创项目/富创项目_会议删除推送.csv') # csv_file_path = os.path.join(current_dir, '../../../测试数据/MQTT模块/富创项目/富创项目_会议删除推送.csv')
# 底图更新的CSV文件路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/MQTT模块/富创项目/富创项目_门口屏底图更新.csv')
if __name__ == "__main__": if __name__ == "__main__":
# 读取配置文件 # 读取配置文件
configs = Mqtt.read_config_from_csv(csv_file_path) configs = Mqtt.read_config_from_csv(csv_file_path)
broker_address = "192.168.5.218" broker_address = "nat.ubainsyun.com"
port = 1883 port = 30413
num_repeats = 1000 # 重复执行的次数 num_repeats = 1000 # 重复执行的次数
interval_between_repeats = 0.2 # 每次重复之间的间隔时间(秒) interval_between_repeats = 20 # 每次重复之间的间隔时间(秒)
# 创建 MQTT 客户端实例 # 创建 MQTT 客户端实例
mqtt_client = Mqtt(broker_address, port) mqtt_client = Mqtt(broker_address, port)
......
...@@ -85,11 +85,11 @@ start_workers(3) ...@@ -85,11 +85,11 @@ start_workers(3)
# 定时执行展厅巡检任务 # 定时执行展厅巡检任务
# schedule.every().day.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") # schedule.every().day.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().monday.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().monday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().thursday.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().thursday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().wednesday.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().wednesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().tuesday.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().tuesday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().friday.at("07:45").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().friday.at("07:42").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
# 调试使用 # 调试使用
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论