提交 30419c4e authored 作者: 彭甘宇's avatar 彭甘宇

Merge branch 'develop' of http://git.ubainsyun.com/bing/ubains-module-test into develop

...@@ -292,7 +292,7 @@ def get_latest_report_file(report_dir, base_url): ...@@ -292,7 +292,7 @@ def get_latest_report_file(report_dir, base_url):
last_modified_time = datetime.fromtimestamp(os.path.getmtime(latest_file)).strftime('%Y-%m-%d %H:%M:%S') last_modified_time = datetime.fromtimestamp(os.path.getmtime(latest_file)).strftime('%Y-%m-%d %H:%M:%S')
# 记录最新报告文件的信息 # 记录最新报告文件的信息
logging.info(f"最新报告文件: {latest_file}, 最后修改时间: {last_modified_time}") logging.info(f"最新文件: {latest_file}, 最后修改时间: {last_modified_time}")
# 将文件路径转换为相对于基础URL的相对路径 # 将文件路径转换为相对于基础URL的相对路径
relative_path = os.path.relpath(latest_file, report_dir) relative_path = os.path.relpath(latest_file, report_dir)
...@@ -306,7 +306,7 @@ def get_latest_report_file(report_dir, base_url): ...@@ -306,7 +306,7 @@ def get_latest_report_file(report_dir, base_url):
def get_reportfile_send_dingding(report_title, report_url_prefix): def get_reportfile_send_dingding(report_title, report_url_prefix):
try: try:
# 获取报告文件所在的目录 # 获取文件所在的目录
report_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..','log') report_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..','log')
# 获取基础URL # 获取基础URL
......
from time import sleep
from appium.webdriver.common.appiumby import AppiumBy
from dominate.tags import button
from pygments.console import light_colors
import logging
from time import sleep
from appium.options.android import UiAutomator2Options from appium.options.android import UiAutomator2Options
import logging import logging
from selenium import webdriver from selenium import webdriver
...@@ -51,7 +57,7 @@ import logging ...@@ -51,7 +57,7 @@ import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def compare_brightness(light_down_path, light_on_path, threshold=50): def compare_brightness(light_down_path, light_on_path, threshold=1):
""" """
对比两张图片的亮度,返回亮度是否增加的布尔值。 对比两张图片的亮度,返回亮度是否增加的布尔值。
light_on_path:传入暗色的图片 light_on_path:传入暗色的图片
...@@ -84,8 +90,8 @@ def compare_brightness(light_down_path, light_on_path, threshold=50): ...@@ -84,8 +90,8 @@ def compare_brightness(light_down_path, light_on_path, threshold=50):
# if __name__ == '__main__': # if __name__ == '__main__':
# logging.info("开始对比亮度") # logging.info("开始对比亮度")
# #
# image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg' # image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame2.jpg'
# image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.jpg' # image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame.jpg'
# #
# # 检查图片路径是否存在 # # 检查图片路径是否存在
# if not os.path.exists(image1_path): # if not os.path.exists(image1_path):
...@@ -142,66 +148,259 @@ def compare_images_feature_matching(image1_path, image2_path): ...@@ -142,66 +148,259 @@ def compare_images_feature_matching(image1_path, image2_path):
return False return False
if __name__ == '__main__': # if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("开始对比图片") # logging.info("开始对比图片")
#
# image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame2.jpg'
# image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame.jpg'
#
# 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)
#
# # 对比两张截图的相似度
# if compare_images_feature_matching(image1_path, image2_path):
# logging.info("图片相同")
# else:
# logging.error("图片不同")
image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg' import cv2
image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.jpg' import logging
import os
import shutil # 导入 shutil 模块以检查磁盘空间
if not os.path.exists(image1_path): # 配置日志
logging.error(f"图片 {image1_path} 不存在") logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
exit(1)
if not os.path.exists(image2_path):
logging.error(f"图片 {image2_path} 不存在")
exit(1)
# 对比两张截图的相似度 def check_output_path(output_path):
if compare_images_feature_matching(image1_path, image2_path): output_dir = os.path.dirname(output_path)
logging.info("图片相同") if not os.path.exists(output_dir):
else: try:
logging.error("图片不同") os.makedirs(output_dir)
logging.info(f"创建目录: {output_dir}")
except Exception as e:
logging.error(f"无法创建目录 {output_dir}: {e}")
return False
# 检查文件权限
if not os.access(output_dir, os.W_OK):
logging.error(f"没有写权限: {output_dir}")
return False
return True
def capture_frame_from_rtsp(rtsp_url, output_path):
def capture_frame_from_rtsp(rtsp_url, file_name, output_path=None):
""" """
从RTSP流中捕获一帧并保存为图像文件。 从RTSP流中捕获一帧并保存为图像文件。
""" """
try: try:
# 验证输入参数
if not rtsp_url:
logging.error("RTSP URL 为空")
return False
# 获取当前脚本所在的根目录
script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(script_dir)
# 构建默认输出路径
if output_path is None:
output_path = os.path.join(root_dir, "reports", "imgs", "Exhibit_Inspect", "Control_Manage", file_name)
# 检查并创建输出目录
if not check_output_path(output_path):
return False
# 打开RTSP流 # 打开RTSP流
cap = cv2.VideoCapture(rtsp_url) cap = cv2.VideoCapture(rtsp_url)
if not cap.isOpened(): if not cap.isOpened():
logging.error("无法打开RTSP流") logging.error("无法打开RTSP流")
return False return False
# 读取一帧 # 尝试多次读取帧以确保获取有效帧
ret, frame = cap.read() for _ in range(5): # 尝试读取5次
ret, frame = cap.read()
if ret and frame is not None:
break
else:
logging.error("无法从RTSP流中读取有效帧")
cap.release()
return False
if not ret: # 确认帧不为空
logging.error("无法从RTSP流中读取帧") if frame is None or frame.size == 0:
logging.error("捕获到的帧为空")
cap.release() cap.release()
return False return False
# 保存帧为图像文件 # 检查帧的形状和类型
cv2.imwrite(output_path, frame) logging.info(f"捕获到的帧尺寸: {frame.shape}, 数据类型: {frame.dtype}")
logging.info(f"帧已保存到 {output_path}")
# 尝试保存帧为图像文件
success = False
try:
# 使用 cv2.imencode 保存图像到内存中,再写入文件
_, img_encoded = cv2.imencode('.png', frame)
with open(output_path, 'wb') as f:
f.write(img_encoded.tobytes())
success = True
except Exception as e:
logging.error(f"无法保存帧到 {output_path}: {e}")
logging.error(f"检查路径是否存在: {os.path.exists(os.path.dirname(output_path))}")
logging.error(f"检查路径是否可写: {os.access(os.path.dirname(output_path), os.W_OK)}")
# 使用 shutil.disk_usage 检查磁盘空间
try:
total, used, free = shutil.disk_usage(os.path.dirname(output_path))
logging.error(f"检查磁盘空间: {free // (2 ** 20)} MB available")
except Exception as e:
logging.error(f"无法检查磁盘空间: {e}")
if success:
logging.info(f"帧已保存到 {output_path}")
else:
logging.error(f"帧保存失败")
# 释放资源 # 释放资源
cap.release() cap.release()
return True return success
except Exception as e: except Exception as e:
logging.error(f"捕获帧时发生错误: {e}", exc_info=True) logging.error(f"捕获帧时发生错误: {e}", exc_info=True)
return False return False
# if __name__ == '__main__':
if __name__ == '__main__': # # 先截取当前空间的灯光状态图片
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
# logging.info("开始捕获RTSP流中的帧")
# if capture_frame_from_rtsp(rtsp_url,"light_on.png"):
# logging.info("帧捕获成功")
# else:
# logging.error("帧捕获失败")
def light_control(app_drive):
# 开启所有区域灯光
# 定位【接待区】灯光
light_reception_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.ImageView[1]")
sleep(2)
logging.info("尝试定位【接待区】按钮元素,并点击按钮")
light_reception_button.click()
sleep(2)
# 定位【指挥中心】灯光
light_command_center_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[3]")
sleep(2)
logging.info("尝试定位【指挥中心】按钮元素,并点击按钮")
light_command_center_button.click()
sleep(2)
# 定位【影音室】灯光
light_audio_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[2]")
sleep(2)
logging.info("尝试定位【影音室】按钮元素,并点击按钮")
light_audio_room_button.click()
sleep(2)
# 定位【会议室】灯光
light_meeting_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[5]")
sleep(2)
logging.info("尝试定位【会议室】按钮元素,并点击按钮")
light_meeting_room_button.click()
sleep(2)
# 定位【会商区】灯光
light_meeting_area_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[4]")
sleep(2)
logging.info("尝试定位【会商区】按钮元素,并点击按钮")
light_meeting_area_button.click()
sleep(2)
# 定位【培训室】灯光
light_training_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[6]")
sleep(2)
logging.info("尝试定位【培训室】按钮元素,并点击按钮")
light_training_room_button.click()
sleep(2)
def curtain_control(app_drive):
# 所有窗帘全部上升
logging.info("尝试定位所有【窗帘上升】按钮元素,并点击按钮")
# 上升按钮的定位
curtain_up_locator = ['3', '4', '5', '1', '13']
for i in curtain_up_locator:
curtain_up_button = app_drive.find_element(AppiumBy.XPATH,
f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]")
curtain_up_button.click()
sleep(2)
# 截图获取当前中控屏软件窗帘上升的界面
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\curtain_up.png")
sleep(10)
# 所有窗帘全部下降
logging.info("尝试定位所有【窗帘下降】按钮元素,并点击按钮")
# 下降按钮的定位
curtain_down_locator = ['10', '11', '12', '6', '15']
for i in curtain_down_locator:
curtain_down_button = app_drive.find_element(AppiumBy.XPATH,
f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]")
curtain_down_button.click()
sleep(2)
# 截图获取当前中控屏软件窗帘上升的界面
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\curtain_down.png")
def air_condition_control(app_drive):
# 点击【打开空调】按钮
logging.info("尝试定位【打开空调】按钮元素,并点击按钮")
open_air_conditioner_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[14]")
open_air_conditioner_button.click()
sleep(20)
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_on.png")
sleep(2)
# 点击【关闭空调】按钮
logging.info("尝试定位【关闭空调】按钮元素,并点击按钮")
close_air_conditioner_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[14]")
close_air_conditioner_button.click()
sleep(20)
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_off.png")
sleep(2)
def command_centre_control(rtsp_url,app_drive):
open_center_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button")
open_center_button.click()
sleep(10)
# 从rtsp流中截取一帧保存为图片
logging.info("开始捕获RTSP流中的帧") logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url, "command_screen_on.png"):
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址 logging.info("帧捕获成功")
output_path = "captured_frame.jpg" # 保存帧的路径 else:
logging.error("帧捕获失败")
if capture_frame_from_rtsp(rtsp_url, output_path):
# 关闭指挥中心大屏幕
logging.info("尝试定位【关闭指挥中心控制】按钮元素,并点击按钮")
close_center_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button")
close_center_button.click()
sleep(10)
# 从rtsp流中截取一帧保存为图片
logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url,
"command_screen_down.png"):
logging.info("帧捕获成功") logging.info("帧捕获成功")
else: else:
logging.error("帧捕获失败") logging.error("帧捕获失败")
\ No newline at end of file
...@@ -145,4 +145,10 @@ ...@@ -145,4 +145,10 @@
30. 2024-12-30 30. 2024-12-30
- 封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。 - 封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。
31. 2024-12-31 31. 2024-12-31
- 补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。 - 补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。处理优化调用。
\ No newline at end of file - 补充展厅中开屏的关于灯光控制、窗帘控制、指挥大屏控制以及配合监控视频来判断灯光与指挥大屏是否正确打开。
- 优化capture_frame_from_rtsp函数的异常判断。
- 封装中控屏对应控制模块函数,减少主函数的代码冗杂,增加可维护性。
32. 2025-01-02
- 调整优化内部参会人。
- 处理展厅会议室内中控屏的摄像头跟踪功能,并打开无纸化升降屏。调整优化。
\ No newline at end of file
...@@ -25,8 +25,52 @@ def suite_setup(): ...@@ -25,8 +25,52 @@ def suite_setup():
wd = GSTORE['wd'] wd = GSTORE['wd']
admin_login("Test02", "ubains@123") admin_login("Test02", "ubains@123")
sleep(5) sleep(5)
INFO("请检查中控屏软件灯光开启的状态是否正常")
STEP(2, "检查灯光开启状态")
# 这是全部灯光关闭后在软件界面上的状态显示
INFO("请检查中控屏软件的灯光关闭状态显示是否正常")
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Control_Manage","light_all_off")
# 这是全部灯光开启后在软件界面上的状态显示
INFO("请检查中控屏软件的灯光开启状态显示是否正常")
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Control_Manage","light_all_on")
# 这是灯光开启前的截图
INFO("请检查灯光开启前的监控视频状态是否正常")
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Control_Manage","light_down")
# 这是灯光开启后的截图
INFO("请检查灯光开启后的监控视频状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "light_on")
STEP(3, "检查窗帘的上升下降状态")
INFO("请检查窗帘上升状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_up")
INFO("请检查窗帘下降状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_down")
STEP(3, "检查空调开启状态")
# 这是空调关闭的状态显示
INFO("请检查空调关闭的状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_off")
# 这是空调开启的状态显示
INFO("请检查空调开启的状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_on")
STEP(4, "检查指挥大屏开启状态")
# 这是指挥大屏关闭的监控视频显示
INFO("请检查指挥大屏关闭的监控视频状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "command_screen_down")
# 这是指挥大屏开启的监控视频显示
INFO("请检查指挥大屏开启的监控视频状态是否正常")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "command_screen_on")
STEP(5,"检查音乐播放状态")
# 这是音乐开启播放后的界面显示
INFO("请检查中控屏软件打开音乐播放后的界面状态显示")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_on")
# 这是音乐关闭播放后的界面显示
INFO("请检查中控屏软件关闭音乐播放后的界面状态显示")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_off")
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Tx_meeting","会场画面截屏")
def suite_teardown(): def suite_teardown():
browser_quit() browser_quit()
\ No newline at end of file
from appium.webdriver.common.appiumby import AppiumBy from appium.webdriver.common.appiumby import AppiumBy
from dominate.tags import button
from pygments.console import light_colors
from 预定系统.Base.app_base import * from 预定系统.Base.app_base import *
import logging import logging
from time import sleep from time import sleep
...@@ -12,7 +14,7 @@ class Exhibition_hall_Control_000x: ...@@ -12,7 +14,7 @@ class Exhibition_hall_Control_000x:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --tag 展厅中控屏 2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --tag 展厅中控屏
""" """
tags = ['展厅中控屏'] tags = ['展厅中控屏','展厅巡检']
def teststeps(self): def teststeps(self):
""" """
...@@ -36,6 +38,14 @@ class Exhibition_hall_Control_000x: ...@@ -36,6 +38,14 @@ class Exhibition_hall_Control_000x:
air_button.click() air_button.click()
sleep(20) sleep(20)
# 先截取当前空间的灯光状态图片
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url, "light_down.png"):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
# 定位灯光控制按钮元素,并点击按钮 # 定位灯光控制按钮元素,并点击按钮
logging.info("尝试定位【灯光控制】按钮元素,并点击按钮") logging.info("尝试定位【灯光控制】按钮元素,并点击按钮")
light_button = app_drive.find_element(AppiumBy.XPATH, light_button = app_drive.find_element(AppiumBy.XPATH,
...@@ -45,55 +55,22 @@ class Exhibition_hall_Control_000x: ...@@ -45,55 +55,22 @@ class Exhibition_hall_Control_000x:
light_button.click() light_button.click()
logging.info("点击【灯光控制】按钮成功") logging.info("点击【灯光控制】按钮成功")
sleep(20) sleep(20)
# 截图获取当前软件的灯光控制界面
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_off.png")
# 调用灯光控制函数
light_control(app_drive)
# 截图获取当前软件的灯光控制界面
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_on.png")
# 先截取当前空间的灯光状态图片
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url, "light_on.png"):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
# 开启所有区域灯光
# 定位【接待区】灯光
light_reception_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.ImageView[1]")
sleep(2)
logging.info("尝试定位【接待区】按钮元素,并点击按钮")
light_reception_button.click()
sleep(2)
# 定位【指挥中心】灯光
light_command_center_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[3]")
sleep(2)
logging.info("尝试定位【指挥中心】按钮元素,并点击按钮")
light_command_center_button.click()
sleep(2)
# 定位【影音室】灯光
light_audio_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[2]")
sleep(2)
logging.info("尝试定位【影音室】按钮元素,并点击按钮")
light_audio_room_button.click()
sleep(2)
# 定位【会议室】灯光
light_meeting_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[5]")
sleep(2)
logging.info("尝试定位【会议室】按钮元素,并点击按钮")
light_meeting_room_button.click()
sleep(2)
# 定位【会商区】灯光
light_meeting_area_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[4]")
sleep(2)
logging.info("尝试定位【会商区】按钮元素,并点击按钮")
light_meeting_area_button.click()
sleep(2)
# 定位【培训室】灯光
light_training_room_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[6]")
sleep(2)
logging.info("尝试定位【培训室】按钮元素,并点击按钮")
light_training_room_button.click()
sleep(2)
# 切换至窗帘控制界面 # 切换至窗帘控制界面
logging.info("尝试定位【窗帘控制】按钮元素,并点击按钮") logging.info("尝试定位【窗帘控制】按钮元素,并点击按钮")
...@@ -101,15 +78,63 @@ class Exhibition_hall_Control_000x: ...@@ -101,15 +78,63 @@ class Exhibition_hall_Control_000x:
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[4]") "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[4]")
curtain_button.click() curtain_button.click()
sleep(2) sleep(2)
# 所有窗帘全部上升 # 调用窗口上升下降的函数
logging.info("尝试定位【窗帘上升】按钮元素,并点击按钮") curtain_control(app_drive)
for i in range(1, 6):
logging.info(f"尝试定位第{i}个【窗帘上升】按钮元素,并点击按钮") # 切换至空调控制界面
curtain_up_button = app_drive.find_element(AppiumBy.XPATH, logging.info("尝试定位【空调控制】按钮元素,并点击按钮")
f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]") air_conditioner_button = app_drive.find_element(AppiumBy.XPATH,
curtain_up_button.click() "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[5]")
sleep(2) air_conditioner_button.click()
sleep(2)
# 调用空调控制的函数
air_condition_control(app_drive)
# 切换至指挥中心控制界面
# 打开指挥中心大屏幕
logging.info("尝试定位【开启指挥中心控制】按钮元素,并点击按钮")
center_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.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[8]")
center_button.click()
sleep(2)
# 调用指挥中心控制函数
command_centre_control(rtsp_url, app_drive)
# 切换至音乐区域
logging.info("尝试定位【音乐】按钮元素,并点击按钮")
music_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.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[9]")
music_button.click()
sleep(2)
# 点击【播放音乐】
logging.info("尝试定位【播放音乐】按钮元素,并点击按钮")
play_music_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[8]")
play_music_button.click()
sleep(5)
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\music_on.png")
# 点击【关闭播放音乐】
logging.info("尝试定位【关闭播放音乐】按钮元素,并点击按钮")
close_play_music_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.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[8]")
close_play_music_button.click()
sleep(5)
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\music_off.png")
# 切换灯光控制界面
# 所有测试结束后关闭灯光
logging.info("尝试定位【灯光控制】按钮元素,并点击按钮")
light_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.RelativeLayout/android.widget.RelativeLayout/android.widget.Button[3]")
logging.info("定位成功")
# 点击【灯光控制】按钮
light_button.click()
sleep(10)
light_control(app_drive)
except Exception as e: except Exception as e:
# 捕获并记录任何发生的错误 # 捕获并记录任何发生的错误
......
...@@ -154,8 +154,8 @@ class Exhibition_hall_inspection_000x: ...@@ -154,8 +154,8 @@ class Exhibition_hall_inspection_000x:
sleep(1) sleep(1)
# 根据参会人名称搜搜对应参会人 # 根据参会人名称搜搜对应参会人
ipn = ['赵嘉诚','CZJ','向彩娇','马晓丽','王兵','陈林','李立键','丁海洪','刘建胜','潘松林','卢培锽','黄史恭','罗一龙','彭甘宇'] ipn = ['赵嘉诚','CZJ','马晓丽','王兵','陈林','李立键','丁海洪','刘建胜','潘松林','卢培锽','黄史恭','罗一龙','彭甘宇']
for i in range(0, 14): for i in range(0, 13):
safe_send_keys((By.XPATH, "//input[@placeholder='账号/用户名']"), ipn[i], wd) safe_send_keys((By.XPATH, "//input[@placeholder='账号/用户名']"), ipn[i], wd)
send_keyboard((By.XPATH, "//input[@placeholder='账号/用户名']"), wd) send_keyboard((By.XPATH, "//input[@placeholder='账号/用户名']"), wd)
sleep(1) sleep(1)
......
...@@ -10,7 +10,7 @@ class Exhibition_hall_NoPaperinspection_000x: ...@@ -10,7 +10,7 @@ class Exhibition_hall_NoPaperinspection_000x:
""" """
执行指令: 执行指令:
1.cd 预定系统 1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --tag 展厅巡检_无纸化 2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --tag 无纸化
""" """
tags = ['展厅巡检','无纸化'] tags = ['展厅巡检','无纸化']
...@@ -19,7 +19,7 @@ class Exhibition_hall_NoPaperinspection_000x: ...@@ -19,7 +19,7 @@ class Exhibition_hall_NoPaperinspection_000x:
try: try:
# 腾讯:"com.tencent.wemeet.app" ".StartupActivity" # 腾讯:"com.tencent.wemeet.app" ".StartupActivity"
# 无纸化1.0:"com.ubains.system.develop.mqtt" "com.ubains.system.activity.RouterActivity" # 无纸化1.0:"com.ubains.system.develop.mqtt" "com.ubains.system.activity.RouterActivity"
app_drive = app_setup_driver("Android", "7.1.2", "展厅无纸化设备1.0", "com.ubains.system.develop.mqtt", "com.ubains.system.activity.RouterActivity","192.168.5.159:5555") app_drive = app_setup_driver("Android", "7.1.2", "展厅无纸化设备1.0", "com.ubains.system.develop.mqtt", "com.ubains.system.activity.RouterActivity","192.168.5.158:5555")
app_drive.implicitly_wait(20) # 设置缺省等待时间 app_drive.implicitly_wait(20) # 设置缺省等待时间
# 使用显式等待来等待元素出现 # 使用显式等待来等待元素出现
...@@ -87,6 +87,24 @@ class Exhibition_hall_NoPaperinspection_000x: ...@@ -87,6 +87,24 @@ class Exhibition_hall_NoPaperinspection_000x:
# swipe_up(app_drive) # swipe_up(app_drive)
sleep(2) sleep(2)
# # 尝试点击左侧的侧边栏
# sidebar_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.RelativeLayout/android.widget.LinearLayout[2]/android.widget.RelativeLayout/android.widget.TextView")
# sidebar_button.click()
# sleep(2)
#
# # 尝试定位同屏按钮
# same_screen = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.RelativeLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[6]/android.widget.ImageView")
# same_screen.click()
# sleep(2)
#
# # 尝试点位【发起同屏】按钮
# initiate_same_screen = app_drive.find_element(AppiumBy.XPATH,
# "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[1]")
# initiate_same_screen.click()
# sleep(2)
except Exception as e: except Exception as e:
logging.error(f"发生错误: {e}", exc_info=True) logging.error(f"发生错误: {e}", exc_info=True)
......
import sys
import os
from time import sleep
# 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建预定系统的绝对路径
预定系统_path = os.path.abspath(os.path.join(current_dir, '..','..','..'))
# 添加路径
sys.path.append(预定系统_path)
# 导入模块
try:
from 预定系统.Base.base import *
except ModuleNotFoundError as e:
print(f"ModuleNotFoundError: {e}")
print("尝试使用绝对路径导入")
from 预定系统.Base.base import *
def suite_setup():
STEP(1, "初始化浏览器")
login_exhibit_url = 'http://192.168.5.200:8080/#/login/logindf'
login_exhibit_ngrok_url = 'http://nat.ubainsyun.com:11060/#/login/logindf'
browser_init(login_exhibit_url)
wd = GSTORE['wd']
admin_login("Test02", "ubains@123")
sleep(5)
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Tx_meeting","会场画面截屏")
def suite_teardown():
browser_quit()
\ No newline at end of file
from 预定系统.Base.app_base import *
import logging
from time import sleep
# 配置日志记录
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
class Exhibition_Meeting_Control_0001:
"""
执行指令:
1.cd 预定系统
2.hytest --report_title 会议预约测试报告 --report_url_prefix http://192.168.1.225 --tag 展厅会议室中控屏
"""
tags = ['展厅会议室中控屏','展厅巡检']
def teststeps(self):
"""
执行测试步骤以自动化测试腾讯会议应用的登录和会议加入流程。
该方法初始化应用驱动,等待应用加载,定位并点击会议按钮,加入会议,并截取会议画面。
"""
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)
# 点击【进入系统】按钮
enter_system_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[9]")
enter_system_button.click()
sleep(20)
logging.info("进入系统")
# 点击【确认】按钮
logging.info("点击【确认】按钮")
confirm_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]")
confirm_button.click()
sleep(10)
# 进入视频会议模式,使用摄像头跟踪功能
logging.info("进入视频会议模式")
video_meeting_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[14]")
video_meeting_button.click()
sleep(20)
# 点击【入住式会议】按钮
logging.info("点击【入住式会议】按钮")
enter_meeting_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[5]/android.widget.Button[2]")
enter_meeting_button.click()
sleep(20)
# 点击【摄像头跟踪】按钮
logging.info("点击【摄像头跟踪】按钮")
camera_tracking_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[5]/android.widget.Button[30]")
camera_tracking_button.click()
sleep(10)
#选择左屏进行摄像头跟踪
logging.info("选择左屏进行摄像头跟踪")
left_screen_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[6]/android.widget.Button[3]")
left_screen_button.click()
sleep(20)
# 返回上一级界面
logging.info("返回上一级界面")
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[6]/android.widget.Button[1]")
back_button.click()
sleep(10)
# 点击无纸化
logging.info("点击无纸化")
no_paper_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[5]/android.widget.Button[10]")
no_paper_button.click()
sleep(30)
# 点击【全部上升】按钮
logging.info("点击【全部上升】按钮")
all_up_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[6]/android.widget.Button[1]")
all_up_button.click()
sleep(30)
except Exception as e:
# 捕获并记录任何发生的错误
logging.error(f"发生错误: {e}", exc_info=True)
finally:
# 确保驱动程序在测试结束后正确关闭
if app_drive:
app_drive.quit()
logging.info("驱动程序已退出。")
\ No newline at end of file
name,conference_name,message_name,book_start_time,book_end_time,book_check_text name,conference_name,message_name,book_start_time,book_end_time,book_check_text
会议状态设置_001,预约会议室,哈哈哈哈会议,18:00,18:15,预定成功 会议状态设置_001,预约会议室,哈哈哈哈会议,12:15,12:30,预定成功
\ No newline at end of file \ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论