feat: open browser with stable CDP port for scrape attach
All checks were successful
技能自动化发布 / release (push) Successful in 11s

This commit is contained in:
2026-09-16 15:40:50 +08:00
parent 71b20e6e4a
commit 1ba7a0f4a1
4 changed files with 44 additions and 5 deletions

View File

@@ -193,6 +193,7 @@ class TestHumanChromeLaunchArgs:
for flag in HUMAN_CHROME_FLAGS:
assert flag in args
assert "--restore-last-session" not in args
assert any(a.startswith("--remote-debugging-port=") for a in args)
assert args[-1] == "https://chat.deepseek.com"
assert "--enable-automation" not in args
@@ -201,6 +202,7 @@ class TestHumanChromeLaunchArgs:
args = human_chrome_launch_args(str(tmp_path / "prof"), None, restore_session=True)
assert "--restore-last-session" in args
assert any(a.startswith("--remote-debugging-port=") for a in args)
assert not any(a.startswith("http") for a in args)
def test_shortcut_arguments_quote_profile_and_include_url(self, tmp_path):
@@ -213,6 +215,7 @@ class TestHumanChromeLaunchArgs:
assert "--start-maximized" in text
assert "--no-first-run" in text
assert "--restore-last-session" not in text
assert "--remote-debugging-port=" in text
assert text.endswith("https://example.com")
def test_shortcut_restore_session(self, tmp_path):
@@ -220,8 +223,16 @@ class TestHumanChromeLaunchArgs:
text = human_chrome_shortcut_arguments(str(tmp_path / "p"), None, restore_session=True)
assert "--restore-last-session" in text
assert "--remote-debugging-port=" in text
assert "http" not in text
def test_cdp_port_stable_for_profile(self, tmp_path):
from service.browser_service import cdp_port_for_profile
p = str(tmp_path / "prof")
assert cdp_port_for_profile(p) == cdp_port_for_profile(p)
assert 9330 <= cdp_port_for_profile(p) < 9390
class TestResolveChromiumChannel:
"""resolve_chromium_channel returns a channel string when browsers exist."""