TBC/framework/scripts/three_d_generation_scenario.py
d-robotics 633a797226 AutoFlow v2.0: 合并 Test (Robogo) + data-loop-automation (D-Cloud) 为统一平台
- 16 个业务模块,856 个测试用例,40 个 E2E 测试
- 单一 React 19 前端 + PlatformSwitcher 二合一切换
- Flask 后端支持 scenario/dcloud_module/dcloud_e2e/dcloud_all 四种任务类型
- E2E 测试面板:API 全链路(8条) + UI 点击(3条) + 分步测试(3个)
- SSE 实时日志流 + 飞书告警 + 定时调度
- 完整还原原 ToB 平台 TestPanel E2E 模块
2026-06-23 11:48:29 +08:00

47 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
import random
import time
from framework.core.logger import get_logger
from framework.config.settings import Config
logger = get_logger("ThreeDGenerationScenario")
def run_3d_generation_lifecycle(threed_page):
"""
业务逻辑:3D 生成 + 右上角保存全流程
"""
logger.info("--- 开启 3D 生成场景测试 (包含生成后保存) ---")
threed_page.navigate_to()
# 1. 随机选取一张 PNG 素材
test_data_dir = Config.TEST_DATA_DIR
png_files = [f for f in os.listdir(test_data_dir) if f.lower().endswith('.png')]
if not png_files:
logger.warning(f"⚠️ 目录 {test_data_dir} 下没发现 PNG, 尝试使用默认素材")
return
random_pic = random.choice(png_files)
pic_path = os.path.join(test_data_dir, random_pic)
# 调试
#threed_page.page.pause()
logger.info(f"🎲 随机选取的素材为: {random_pic}")
# 2. 上传并触发生成
threed_page.upload_image(pic_path)
time.sleep(1)
if threed_page.start_generation():
# 3. 等待生成结果出现并点击保存
if threed_page.wait_for_result_and_save():
# 4. 执行复杂的保存弹窗流程 (含随机命名与路径选择)
asset_name = threed_page.handle_save_dialog()
logger.info(f"✨ 3D 模型巡检完毕,资产 {asset_name} 已保存")
return asset_name
else:
logger.error("❌ 等待结果超时,未进入保存流程")
else:
logger.error("❌ 无法点击生成按钮,场景中断")
return None