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

处理展厅中控屏图片过大问题,优化处理。初步调试测试用例JSON数据读取。

上级 fbd74763
......@@ -412,12 +412,15 @@ def curtain_control(app_drive,wd):
curtain_up_button.click()
sleep(2)
INFO("请检查窗帘上升状态是否正常")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_up")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_up")
# 截图获取当前中控屏软件窗帘上升的界面
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "curtain_up")
app_drive.get_screenshot_as_file(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\curtain_up.png")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "curtain_up")
sleep(30)
# # 测试报告中补充窗帘上升的截图
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_rtsp_up")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_rtsp_up")
# 通过rtsp流获取当前窗帘的上升效果图
curtain_rtsp_url = "rtsp://admin:huawei@123@192.168.4.18/LiveMedia/ch1/Media2"
logging.info("开始捕获RTSP流中的帧")
......@@ -437,9 +440,10 @@ def curtain_control(app_drive,wd):
sleep(2)
sleep(30)
INFO("请检查窗帘下降状态是否正常")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_down")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_down")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\curtain_down.png")
# 截图获取当前中控屏软件窗帘上升的界面
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "curtain_down")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "curtain_down")
# 测试报告中补充窗帘下降的截图
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "curtain_rtsp_down")
logging.info("开始捕获RTSP流中的帧")
......@@ -458,9 +462,9 @@ def air_condition_control(app_drive,wd):
# 这是空调开启的状态显示
INFO("请检查空调开启的状态是否正常")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_on")
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "air_condition_on")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_on")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_on.png")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "air_condition_on")
sleep(2)
# 点击【关闭空调】按钮
......@@ -471,8 +475,9 @@ def air_condition_control(app_drive,wd):
sleep(20)
# 这是空调关闭的状态显示
INFO("请检查空调关闭的状态是否正常")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_off")
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "air_condition_off")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "air_condition_off")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_off.png")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "air_condition_off")
sleep(2)
def information_control(app_drive,wd):
......@@ -552,8 +557,9 @@ def music_control(app_drive,wd):
sleep(5)
# 这是音乐开启播放后的界面显示
INFO("请检查中控屏软件打开音乐播放后的界面状态显示")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_on")
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "music_on")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_on")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\music_on.png")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "music_on")
# 点击【关闭播放音乐】
logging.info("尝试定位【关闭播放音乐】按钮元素,并点击按钮")
......@@ -563,8 +569,9 @@ def music_control(app_drive,wd):
sleep(5)
# 这是音乐关闭播放后的界面显示
INFO("请检查中控屏软件关闭音乐播放后的界面状态显示")
# SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_off")
get_screenshot_with_retry(wd,app_drive, "Control_Manage", "music_off")
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "music_off")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\music_off.png")
# get_screenshot_with_retry(wd,app_drive, "Control_Manage", "music_off")
def command_centre_control(rtsp_url,app_drive,wd):
open_center_button = app_drive.find_element(AppiumBy.XPATH,
......
......@@ -227,4 +227,6 @@
- 处理展厅巡检中控屏的信息发布屏流程步骤缺失问题,增加异常重试机制。
- 封装三个移动端的函数,分别用于设备控制时的异常重试机制以及设备截屏操作,增加相应的异常处理。
59. 2025-02-26
- 优化MQTT模块增加账号密码输入,输出通过读取测试用例的JSON数据格式进行自动化测试的demo程序。
\ No newline at end of file
- 优化MQTT模块增加账号密码输入,输出通过读取测试用例的JSON数据格式进行自动化测试的demo程序。
60. 2025-02-28
- 处理展厅中控屏图片过大问题,优化处理。初步调试测试用例JSON数据读取。
\ No newline at end of file
import sys
import os
import openpyxl
import json
from 预定系统.Base.base import INFO
# 获取当前脚本的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
......@@ -16,45 +19,90 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建CSV文件的绝对路径
csv_file_path = os.path.join(current_dir, '../../../测试数据/登录模块/新账号密码登录.xlsx')
def read_xlsx_data(xlsx_file_path):
"""
读取XLSX文件中的数据,并将其转换为一个包含字典的列表,每个字典代表一行测试用例数据。
参数:
xlsx_file_path (str): XLSX文件的路径。
返回:
list: 包含字典的列表,每个字典包含测试用例的名称和参数。
"""
# 打开XLSX文件
workbook = openpyxl.load_workbook(xlsx_file_path)
# 假设数据在第一个工作表中
sheet = workbook.active
# 读取表头,从第三行开始
headers = [cell.value for cell in sheet[3]]
# 打印表头列名
# print(f"表头列名: {headers}")
# 找到表头中名为 'JSON' 的列索引
try:
json_index = headers.index('JSON')
except ValueError as e:
raise ValueError(f"表头中没有找到所需的列: {e}")
ddt_cases = []
# 遍历XLSX文件中的每一行数据,从第四行开始
for row in sheet.iter_rows(min_row=4, values_only=True):
# 获取 JSON 列的数据
json_data = row[json_index]
# 打印 JSON 数据以进行调试
# print(f"JSON 数据: {json_data}")
# 解析 JSON 字符串
try:
if json_data:
parsed_json = json.loads(json_data)
else:
raise ValueError("JSON 数据为空")
except json.JSONDecodeError:
raise ValueError(f"无法解析 JSON 数据: {json_data}")
# 将解析后的 JSON 数据添加到列表中
ddt_cases.append(parsed_json)
# 打印解析后的数据
for case in ddt_cases:
for step in case:
print(f"页面: {step['page']}")
print(f"按钮XPath: {step['btnXpath']}")
if 'input' in step:
print(f"输入值: {step['input']}")
if 'receive' in step:
print(f"预期接收: {step['receive']}")
if 'success' in step:
print(f"成功标志: {step['success']}")
# 日志记录:XLSX文件已读取
INFO("XLSX文件已读取")
# 返回包含所有测试用例数据的列表
return ddt_cases
if __name__ == '__main__':
ddt_cases = read_xlsx_data(csv_file_path)
print(ddt_cases)
# 遍历 ddt_cases 并获取每一个 JSON 对象
for case in ddt_cases:
for step in case:
print(f"当前步骤: {step}")
# 你可以在这里对 step 进行进一步处理
# 例如:访问特定字段
page = step.get('page')
btn_xpath = step.get('btnXpath')
input_value = step.get('input')
receive = step.get('receive')
success = step.get('success')
# 假设我们只处理第一个测试用例
if ddt_cases:
first_case = ddt_cases[0]
function_name = first_case['function']
locator_json = first_case['locator_json']
data_json = first_case['data_json']
# 提取定位器和数据
element_locators = locator_json.get('PageData', {})
element_value = data_json.get('testData', {})
username_value = element_value.get('username')
password_value = element_value.get('password')
verifycode_value = element_value.get('verifycode')
# 构造正确的定位器元组
type_value = get_by_enum(element_locators.get('type'))
username_locator_value = element_locators.get('username_locator_value')
password_locator_value = element_locators.get('password_locator_value')
verifycode_locator_value = element_locators.get('verifycode_locator_value')
submit_button_locator_value = element_locators.get('submitButton_locator_value')
# 初始化浏览器
browser_init("标准版预定系统")
# 构造定位器元组
username_locator = (type_value, username_locator_value)
password_locator = (type_value, password_locator_value)
verifycode_locator = (type_value, verifycode_locator_value)
submit_button_locator = (type_value, submit_button_locator_value)
# 调用 user_login 函数
user_login({
'username_locator': username_locator,
'password_locator': password_locator,
'verifycode_locator': verifycode_locator,
'submitButton_locator': submit_button_locator
}, username_value, password_value, verifycode_value)
print(f"页面: {page}")
print(f"按钮XPath: {btn_xpath}")
print(f"输入值: {input_value}")
print(f"预期接收: {receive}")
print(f"成功标志: {success}")
......@@ -61,21 +61,19 @@ class Exhibition_hall_Control_000x:
# 这是全部灯光关闭后在软件界面上的状态显示
INFO("请检查中控屏软件的灯光关闭状态显示是否正常")
# SELENIUM_LOG_SCREEN(wd, "75%", "Exhibit_Inspect", "Control_Manage", "light_all_off")
SELENIUM_LOG_SCREEN(wd, "75%", "Exhibit_Inspect", "Control_Manage", "light_all_off")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_off.png")
# 截图获取当前软件的灯光控制界面
get_screenshot_with_retry(wd,app_drive,
"Control_Manage", "light_all_off")
# get_screenshot_with_retry(wd,app_drive,"Control_Manage", "light_all_off")
# 调用灯光控制函数
light_control(app_drive)
# 这是全部灯光开启后在软件界面上的状态显示
INFO("请检查中控屏软件的灯光开启状态显示是否正常")
SELENIUM_LOG_SCREEN(wd, "75%", "Exhibit_Inspect", "Control_Manage", "light_all_on")
app_drive.get_screenshot_as_file(r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_on.png")
# 截图获取当前软件的灯光控制界面
get_screenshot_with_retry(wd,app_drive,
"Control_Manage", "light_all_on")
# get_screenshot_with_retry(wd,app_drive,"Control_Manage", "light_all_on")
# 这是灯光开启后的截图
INFO("请检查灯光开启后的监控视频状态是否正常")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论