Test_Agent/framework/scripts/three_d_generation_scenario.py
jiawei.chen 6f6053ff51 feat: TestAgent 智能测试平台 v1.0
- CLI + Web 双平台,基于 LLM 的 TDD+DDD 自动化测试生成
- 集成 unified-test-platform 903 个 D-Cloud 用例 + 13 个 Robogo 场景
- Agent 5 步流水线: 扫描 -> DDD -> LLM 生成测试
- 精确回归 + UI 变更检查
- 可视化 HTML 测试报告
- 暗色/亮色主题切换
- 19 个 API 端点 + 6 个 SPA 页面
- 15/15 项 TDD+DDD 合规
2026-07-08 11:27:38 +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 tests.logger import get_logger
from 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