autool/web_start.py
2026-06-17 19:44:18 +08:00

57 lines
1.6 KiB
Python
Raw 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.

#!/usr/bin/env python3
import subprocess
import os
def main():
"""
简化版Web测试启动脚本
直接指定URL进行DroidBot测试
参数已在脚本中写死
"""
URL = "https://www.baidu.com" # 要测试的Web应用URL
OUTPUT_DIR = "./output/web/" # 结果输出目录
BROWSER = "chrome" # 使用的浏览器
POLICY = "memory_guided" # 测试策略
TIMEOUT = 3600 # 测试超时时间(秒)
HEADLESS = False # 是否使用无头模式
ENABLE_GUIAGENT = False # 是否启用GUI Agent
INTERVAL = 0.3
# 构建DroidBot命令
cmd_parts = [
"python", "./DroidBot/start.py",
"-package", URL, # Web平台使用URL作为package参数
"-policy", POLICY,
"-timeout", str(TIMEOUT),
"-o", OUTPUT_DIR,
"-platform", "web",
"-browser", BROWSER,
"-interval", str(INTERVAL)
]
if HEADLESS:
cmd_parts.append("-headless")
if ENABLE_GUIAGENT:
cmd_parts.append("-enable_guiagent")
cmd_str = " ".join(cmd_parts)
# 执行命令
print(f"执行DroidBot Web测试命令:")
print(cmd_str)
print("\n开始测试...\n")
try:
# 直接在终端执行命令并显示输出
subprocess.run(cmd_str, shell=True, check=True)
print(f"\n[SUCCESS] Web测试完成")
except subprocess.CalledProcessError as e:
print(f"\n[ERROR] DroidBot执行失败退出码: {e.returncode}")
except KeyboardInterrupt:
print(f"\n[INFO] 用户中断测试")
if __name__ == "__main__":
main()