feat: 新增浏览器自动化插件 (browser_auto)

基于 Playwright 的无头浏览器操控,33 个操作:
- 连接: start/stop/status
- 导航: open/back/forward/reload/title/url
- 交互: click/fill/select/check/hover/press
- 提取: text/html/attr/value/eval/query
- 截图: screenshot (全页/元素)
- 等待: wait/wait-gone/wait-url
- 高级: pdf/cookies/set-cookie/viewport/download

测试: 101 个用例全部通过
This commit is contained in:
xiaoli-cli committed 2026-04-26 05:46:45 +08:00
1 parent e92c000087
commit 9a711dc809
2 files changed
+580

No files matched your search

+31
View File
@@ -322,6 +322,37 @@ class TestTaskManager:
assert "已清除" in result
# ══════════════════════════════════════
# 引擎加载测试
# ══════════════════════════════════════
class TestBrowserAuto:
"""browser_auto 功能测试"""
@pytest.fixture
def browser(self):
mod = load_module("browser_auto", os.path.join(PLUGINS_DIR, "browser_auto.py"))
return mod.Plugin()
def test_status_stopped(self, browser):
result = browser.handle("status")
assert "未运行" in result
def test_invalid_operation(self, browser):
result = browser.handle("nonexistent")
assert "错误" in result
def test_empty_args(self, browser):
result = browser.handle("")
assert "错误" in result
def test_tool_info(self, browser):
info = browser.get_tool_info()
assert info["name"] == "browser_auto"
assert "浏览器" in info["description"]
assert len(info["keywords"]) > 0
# ══════════════════════════════════════
# 引擎加载测试
# ══════════════════════════════════════