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

补充展厅无纸化中控2.0的同屏巡检代码。

上级 a53882ab
...@@ -744,7 +744,7 @@ def get_screenshot_with_retry(wd,app_drive, module_name, function_name, max_retr ...@@ -744,7 +744,7 @@ def get_screenshot_with_retry(wd,app_drive, module_name, function_name, max_retr
file_path = os.path.join(target_dir, f"{function_name}.png") file_path = os.path.join(target_dir, f"{function_name}.png")
#截屏 #截屏
SELENIUM_LOG_SCREEN(wd, "75%", "Exhibit_Inspect", "Control_Manage", f"{function_name}") SELENIUM_LOG_SCREEN(wd, "75%", "Exhibit_Inspect", module_name, f"{function_name}")
# 使用循环实现重试机制 # 使用循环实现重试机制
for _ in range(max_retries): for _ in range(max_retries):
...@@ -761,7 +761,7 @@ def get_screenshot_with_retry(wd,app_drive, module_name, function_name, max_retr ...@@ -761,7 +761,7 @@ def get_screenshot_with_retry(wd,app_drive, module_name, function_name, max_retr
# 如果多次尝试均失败,则抛出异常 # 如果多次尝试均失败,则抛出异常
raise Exception(f"多次尝试截图失败: {file_path}") raise Exception(f"多次尝试截图失败: {file_path}")
def find_element_with_retry(driver, by, value, max_retries=3, retry_delay=5): def find_element_with_retry(app_driver, by, value, max_retries=3, retry_delay=5):
""" """
使用重试机制查找元素。 使用重试机制查找元素。
...@@ -785,7 +785,7 @@ def find_element_with_retry(driver, by, value, max_retries=3, retry_delay=5): ...@@ -785,7 +785,7 @@ def find_element_with_retry(driver, by, value, max_retries=3, retry_delay=5):
for _ in range(max_retries): for _ in range(max_retries):
try: try:
# 尝试查找元素,如果成功则立即返回元素 # 尝试查找元素,如果成功则立即返回元素
return driver.find_element(by, value) return app_driver.find_element(by, value)
except Exception as e: except Exception as e:
# 如果查找元素失败,记录日志并等待一段时间后重试 # 如果查找元素失败,记录日志并等待一段时间后重试
logging.warning(f"查找元素失败,重试中... ({e})") logging.warning(f"查找元素失败,重试中... ({e})")
......
...@@ -236,3 +236,5 @@ ...@@ -236,3 +236,5 @@
- 排查展厅巡检报告中的异常,处理会场名称变动,导致会场搜索失败问题,改为模糊查询与CSS定位,处理腾讯软终端元素变动问题。 - 排查展厅巡检报告中的异常,处理会场名称变动,导致会场搜索失败问题,改为模糊查询与CSS定位,处理腾讯软终端元素变动问题。
- 排查展厅巡检报告中讯飞语音转录为空的问题。 - 排查展厅巡检报告中讯飞语音转录为空的问题。
- 调整讯飞语音转录的流程,登录讯飞语音转录系统后先判断客户端盒子是否在线,如果在线就进行后续的转录文字提取判断。config.json配置文件增加展厅讯飞系统配置项。 - 调整讯飞语音转录的流程,登录讯飞语音转录系统后先判断客户端盒子是否在线,如果在线就进行后续的转录文字提取判断。config.json配置文件增加展厅讯飞系统配置项。
63. 2025-03-06
- 补充展厅无纸化中控2.0的同屏巡检代码。
\ No newline at end of file
...@@ -6,9 +6,9 @@ class same_screen_share_000x: ...@@ -6,9 +6,9 @@ class same_screen_share_000x:
""" """
执行指令: 执行指令:
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 无纸化1.0同屏
""" """
tags = ['无纸化同屏', '展厅巡检', '无纸化测试'] tags = ['无纸化1.0同屏', '无纸化1.0测试']
def teststeps(self): def teststeps(self):
wd = GSTORE['wd'] wd = GSTORE['wd']
......
from 预定系统.Base.app_base import *
import logging
import time
class same_screen_share_000x:
"""
执行指令:
1.cd 预定系统
2.hytest --report_title 无纸化同屏测试报告 --report_url_prefix http://nat.ubainsyun.com:31133 --tag 无纸化同屏
"""
tags = ['无纸化2.0同屏', '展厅巡检', '无纸化2.0测试']
def teststeps(self):
wd = GSTORE['wd']
app_drive1 = None
app_drive2 = None
try:
# 初始化第一个设备
app_drive1 = app_setup_driver("Android", "7.1.2", "展厅无纸化设备2.0", "com.ubains.local.gviewer", "com.ubains.ub.gview.SplashActivity","192.168.5.156:5555")
app_drive1.implicitly_wait(10) # 设置缺省等待时间
# 初始化第二个设备
app_drive2 = app_setup_driver("Android", "7.1.2", "展厅无纸化设备2.0", "com.ubains.local.gviewer", "com.ubains.ub.gview.SplashActivity","192.168.5.157:5555")
app_drive2.implicitly_wait(10) # 设置缺省等待时间
# 使用显式等待来等待元素出现
logging.info(f"等待登录页加载.")
sleep(10)
# 进入后台设置界面
logging.info(f"尝试进入后台设置")
back_setting_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.Button[3]")
click_with_retry(back_setting_button)
# 输入管理员密码点击【确定】按钮
logging.info(f"尝试输入管理员密码点击【确定】")
admin_pwd_input = find_element_with_retry(app_drive1, AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.EditText")
admin_pwd_input.send_keys("Ubains@123")
sleep(3)
# 点击确定按钮
confirm_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.TextView[3]")
click_with_retry(confirm_button)
sleep(5)
# 先截取另一台设备的界面做参照物
INFO(f"这是设备B的界面")
# 调用截屏函数
get_screenshot_with_retry(wd, app_drive2, "No_PaperLess", "BeforeShareDeviceB")
# 进入【同屏和视频服务】界面
logging.info(f"进入【同屏和视频服务】")
same_screen_module = find_element_with_retry(app_drive1, AppiumBy.XPATH,
'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[3]/android.widget.FrameLayout[1]/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout[4]/android.widget.FrameLayout/android.widget.TextView')
click_with_retry(same_screen_module)
sleep(2)
# 点击右上角【同屏配置】按钮
share_setting_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout[3]/android.widget.FrameLayout[2]/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.Button[1]')
click_with_retry(share_setting_button)
sleep(3)
# 进入同屏配置模块界面,点击【同屏共享】进入同屏共享界面
same_screen_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.TextView")
click_with_retry(same_screen_button)
sleep(2)
# 点击【开始】同屏按钮
same_screen_start_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.viewpager.widget.ViewPager/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/android.widget.Button[1]')
click_with_retry(same_screen_start_button)
sleep(2)
# 截取设备A和设备B的同屏画面截屏
INFO(f"这是设备A同屏共享的界面")
get_screenshot_with_retry(wd, app_drive1, "No_PaperLess", "AfterShareDeviceA")
INFO(f"这是设备B同屏共享的界面")
get_screenshot_with_retry(wd, app_drive2, "No_PaperLess", "AfterShareDeviceB")
# 调用图片对比函数判断相似度
# image1_path = r"/预定系统/reports/imgs/Exhibit_Inspect/No_PaperLess/同屏后-无纸化设备A界面截屏.png"
# image2_path = r"/预定系统/reports/imgs/Exhibit_Inspect/No_PaperLess/同屏后-无纸化设备B界面截屏.png"
#
# if not os.path.exists(image1_path):
# logging.error(f"图片 {image1_path} 不存在")
# exit(1)
# if not os.path.exists(image2_path):
# logging.error(f"图片 {image2_path} 不存在")
# exit(1)
#
# # 对比两张截图的相似度
# result1 = classify_hist_with_split(image1_path, image2_path)
#
# # 确保 result1 是一个标量值
# if isinstance(result1, numpy.ndarray):
# result1 = result1.item()
# # 输出相似度
# INFO("相似度为:" + "%.2f%%" % (result1 * 100))
sleep(1)
# 点击【停止】同屏按钮,退出同屏操作
share_quit_button = find_element_with_retry(app_drive1, AppiumBy.XPATH,
'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/androidx.viewpager.widget.ViewPager/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/android.widget.Button[2]')
INFO("执行退出同屏操作")
click_with_retry(share_quit_button)
# 退出同屏后截屏操作
INFO(f"这是设备A关闭同屏共享的界面")
get_screenshot_with_retry(wd, app_drive1, "No_PaperLess", "QuitShareDeviceA")
INFO(f"这是设备B关闭同屏共享的界面")
get_screenshot_with_retry(wd, app_drive2, "No_PaperLess", "QuitShareDeviceB")
sleep(5)
except Exception as e:
logging.error(f"发生错误: {e}", exc_info=True)
\ No newline at end of file
...@@ -11,9 +11,9 @@ class Exhibition_hall_NoPaperinspection_000x: ...@@ -11,9 +11,9 @@ class Exhibition_hall_NoPaperinspection_000x:
""" """
执行指令: 执行指令:
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 无纸化1.0测试
""" """
tags = ['展厅巡检','无纸化测试'] tags = ['无纸化1.0测试']
def teststeps(self): def teststeps(self):
app_drive = None app_drive = None
......
...@@ -34,7 +34,7 @@ class XF_Meeting_0001: ...@@ -34,7 +34,7 @@ class XF_Meeting_0001:
sleep(1) sleep(1)
# 搜索“展厅巡检”会议数据 # 搜索“展厅巡检”会议数据
INFO("搜索“展厅巡检”会议数据") INFO("搜索“展厅巡检”会议数据")
safe_send_keys((By.XPATH, "//input[@placeholder='输入文件名称']"), "Test02", wd) safe_send_keys((By.XPATH, "//input[@placeholder='输入文件名称']"), "展厅巡检测试", wd)
send_keyboard((By.XPATH, "//input[@placeholder='输入文件名称']"), wd) send_keyboard((By.XPATH, "//input[@placeholder='输入文件名称']"), wd)
sleep(3) sleep(3)
......
...@@ -3,5 +3,5 @@ trust_host_root_certs: false ...@@ -3,5 +3,5 @@ trust_host_root_certs: false
tunnels: tunnels:
nat1: nat1:
proto: proto:
tcp: 192.168.2.254:80 tcp: 192.168.1.228:80
remote_port: 31133 remote_port: 31133
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论