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

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

...@@ -395,7 +395,7 @@ class Mqtt: ...@@ -395,7 +395,7 @@ class Mqtt:
"startTime": config['startTime'], "startTime": config['startTime'],
"endTime": config['endTime'], "endTime": config['endTime'],
"companyNumber": config['companyNumber'], "companyNumber": config['companyNumber'],
"participantList": ["JiaoJiao", "JiaYu", "DuiFangZhengZaiZhangTouFa", "DuoTangMaLaBan"] "participantList": ["JiaoJiao", "JiaYu", "DuiFangZhengZaiZhangTouFa", "DuoTangMaLaBan","czj","czj2"]
}] }]
}) })
......
...@@ -40,4 +40,168 @@ def swipe_up(app_driver): ...@@ -40,4 +40,168 @@ def swipe_up(app_driver):
end_y = int(size['height'] * 0.8) # 结束y坐标,屏幕高度的80% end_y = int(size['height'] * 0.8) # 结束y坐标,屏幕高度的80%
# 执行滑动操作 # 执行滑动操作
app_driver.swipe(start_x, start_y, end_x, end_y, duration=500) app_driver.swipe(start_x, start_y, end_x, end_y, duration=500)
\ No newline at end of file
from PIL import Image
import numpy as np
import os
import logging
# 配置日志记录
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def compare_brightness(light_down_path, light_on_path, threshold=50):
"""
对比两张图片的亮度,返回亮度是否增加的布尔值。
light_on_path:传入暗色的图片
light_down_path:传入亮色的图片
"""
try:
image1 = Image.open(light_down_path).convert('L') # 转换为灰度图像
image2 = Image.open(light_on_path).convert('L') # 转换为灰度图像
# 将图像转换为numpy数组
array1 = np.array(image1)
array2 = np.array(image2)
# 计算平均亮度
avg_brightness1 = np.mean(array1)
avg_brightness2 = np.mean(array2)
logging.info(f"关闭灯光时的平均亮度: {avg_brightness1}")
logging.info(f"打开灯光时的平均亮度: {avg_brightness2}")
# 判断亮度是否增加,考虑阈值
brightness_increase = avg_brightness2 - avg_brightness1
logging.info(f"亮度变化量: {brightness_increase}")
return brightness_increase > threshold
except Exception as e:
logging.error(f"对比亮度时发生错误: {e}", exc_info=True)
return False
# if __name__ == '__main__':
# logging.info("开始对比亮度")
#
# image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg'
# image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.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)
#
# # 对比两张截图的亮度
# result = compare_brightness(image1_path, image2_path)
# logging.info(f"亮度比较结果: {result}")
#
# if result:
# logging.info("灯光已成功打开")
# else:
# logging.error("灯光未成功打开")
import cv2
import numpy as np
def compare_images_feature_matching(image1_path, image2_path):
"""
使用特征匹配对比两张图片的相似度。
"""
try:
image1 = cv2.imread(image1_path, cv2.IMREAD_GRAYSCALE)
image2 = cv2.imread(image2_path, cv2.IMREAD_GRAYSCALE)
# 初始化ORB检测器
orb = cv2.ORB_create()
# 查找关键点和描述符
kp1, des1 = orb.detectAndCompute(image1, None)
kp2, des2 = orb.detectAndCompute(image2, None)
# BFMatcher对象
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# 匹配描述符
matches = bf.match(des1, des2)
# 按距离排序
matches = sorted(matches, key=lambda x: x.distance)
# 计算匹配点的数量
num_matches = len(matches)
logging.info(f"匹配点数量: {num_matches}")
# 判断匹配点数量是否在可接受范围内
return num_matches > 10 # 可以根据需要调整阈值
except Exception as e:
logging.error(f"对比图片时发生错误: {e}", exc_info=True)
return False
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("开始对比图片")
image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg'
image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.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("图片不同")
def capture_frame_from_rtsp(rtsp_url, output_path):
"""
从RTSP流中捕获一帧并保存为图像文件。
"""
try:
# 打开RTSP流
cap = cv2.VideoCapture(rtsp_url)
if not cap.isOpened():
logging.error("无法打开RTSP流")
return False
# 读取一帧
ret, frame = cap.read()
if not ret:
logging.error("无法从RTSP流中读取帧")
cap.release()
return False
# 保存帧为图像文件
cv2.imwrite(output_path, frame)
logging.info(f"帧已保存到 {output_path}")
# 释放资源
cap.release()
return True
except Exception as e:
logging.error(f"捕获帧时发生错误: {e}", exc_info=True)
return False
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("开始捕获RTSP流中的帧")
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
output_path = "captured_frame.jpg" # 保存帧的路径
if capture_frame_from_rtsp(rtsp_url, output_path):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
\ No newline at end of file
...@@ -2,6 +2,8 @@ import csv ...@@ -2,6 +2,8 @@ import csv
import glob import glob
import re import re
import urllib import urllib
import numpy as np
import requests import requests
import json import json
import hmac import hmac
...@@ -734,7 +736,7 @@ def fetch_and_parse_check_txt(url, save_path, extract_info): ...@@ -734,7 +736,7 @@ def fetch_and_parse_check_txt(url, save_path, extract_info):
# 检测文件编码 # 检测文件编码
detected_encoding = chardet.detect(response.content)['encoding'] detected_encoding = chardet.detect(response.content)['encoding']
print(f"检测到的编码: {detected_encoding}") logging.info(f"检测到的编码: {detected_encoding}")
# 如果检测到的编码为空或不准确,可以手动指定编码 # 如果检测到的编码为空或不准确,可以手动指定编码
if not detected_encoding or detected_encoding == 'ascii': if not detected_encoding or detected_encoding == 'ascii':
...@@ -760,5 +762,5 @@ def fetch_and_parse_check_txt(url, save_path, extract_info): ...@@ -760,5 +762,5 @@ def fetch_and_parse_check_txt(url, save_path, extract_info):
return parsed_info return parsed_info
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print(f"请求错误: {e}") logging.exception(f"请求错误: {e}")
return None return None
\ No newline at end of file
...@@ -138,4 +138,11 @@ ...@@ -138,4 +138,11 @@
- 处理优化展厅巡检相关流程。 - 处理优化展厅巡检相关流程。
28. 2024-12-26 28. 2024-12-26
- 调整服务状态监测读取文本文件函数fetch_and_parse_check_txt的重复赋值问题。 - 调整服务状态监测读取文本文件函数fetch_and_parse_check_txt的重复赋值问题。
- 补充展厅巡检关于桌牌系统是否可用的简单检测。 - 补充展厅巡检关于桌牌系统是否可用的简单检测。
\ No newline at end of file - 调整富创数据,调整标准版定时任务的启动标签为预定系统功能,执行预定系统全部功能自动化验证。
29. 2024-12-27
- 补充展厅中控屏的灯光控制以及窗帘控制。
30. 2024-12-30
- 封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。
31. 2024-12-31
- 补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。
\ No newline at end of file
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 appium.webdriver.common.appiumby import AppiumBy
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_hall_Control_000x:
"""
执行指令:
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-13", "com.ubains.gviewer",
".SplashActivity", "192.168.5.112:5555")
app_drive.implicitly_wait(60) # 设置缺省等待时间
# 使用显式等待来等待元素出现
logging.info("等待首页加载...")
# 先切换界面,再切回灯光控制
air_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[6]")
logging.info("尝试定位【空气净化】按钮元素,并点击按钮")
air_button.click()
sleep(20)
# 定位灯光控制按钮元素,并点击按钮
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()
logging.info("点击【灯光控制】按钮成功")
sleep(20)
# 开启所有区域灯光
# 定位【接待区】灯光
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("尝试定位【窗帘控制】按钮元素,并点击按钮")
curtain_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[4]")
curtain_button.click()
sleep(2)
# 所有窗帘全部上升
logging.info("尝试定位【窗帘上升】按钮元素,并点击按钮")
for i in range(1, 6):
logging.info(f"尝试定位第{i}个【窗帘上升】按钮元素,并点击按钮")
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)
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
...@@ -68,13 +68,9 @@ start_workers(3) ...@@ -68,13 +68,9 @@ start_workers(3)
# 定义每天定时执行的任务 # 定义每天定时执行的任务
# 每天早上07:50执行后台系统设置功能测试 # 每天早上07:50执行后台系统设置功能测试
schedule.every().saturday.at("12:00").do(run_task, run_automation_test, report_title="预定系统_后台管理功能_测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="后台管理功能", ding_type="标准版巡检") schedule.every().day.at("10:00").do(run_task, run_automation_test, report_title="预定系统_后台管理功能_测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="预定系统功能", ding_type="标准版巡检")
schedule.every().monday.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检") schedule.every().day.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().tuesday.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().wednesday.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().thursday.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
schedule.every().friday.at("08:05").do(run_task, run_automation_test, report_title="展厅巡检测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检", ding_type="展厅巡检")
# schedule.every().day.at("08:25").do(run_task, run_automation_test, report_title="展厅巡检_腾讯终端入会测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检_腾讯会议") # schedule.every().day.at("08:25").do(run_task, run_automation_test, report_title="展厅巡检_腾讯终端入会测试报告", report_url_prefix="http://nat.ubainsyun.com:31133", test_case="展厅巡检_腾讯会议")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论