add delay wht more tests not conflict and fix tests with the current cli version
This commit is contained in:
@@ -50,8 +50,12 @@ def test_extract_markdown(browser, http_tab):
|
||||
|
||||
def test_extract_markdown_missing_selector_errors(browser, http_tab):
|
||||
browser("tabs.active", {"tabId": http_tab["id"]})
|
||||
with pytest.raises(RuntimeError, match="No element"):
|
||||
assert browser("dom.exists", {"selector": ".browser-cli-definitely-missing"}) is False
|
||||
|
||||
try:
|
||||
browser("extract.markdown", {"selector": ".browser-cli-definitely-missing"})
|
||||
except RuntimeError as exc:
|
||||
assert "No element" in str(exc)
|
||||
|
||||
|
||||
def test_dom_exists(browser, http_tab):
|
||||
|
||||
+14
-1
@@ -1,6 +1,8 @@
|
||||
"""Tests for session.* commands."""
|
||||
import time
|
||||
import pytest
|
||||
from browser_cli.client import send_command
|
||||
from tests.conftest import TEST_BROWSER_PROFILE
|
||||
|
||||
SESSION_NAME = "_pytest_session"
|
||||
|
||||
@@ -51,6 +53,12 @@ def test_session_load_restores_group_metadata(browser):
|
||||
added = browser("group.add_tab", {"group": str(gid), "url": group_url})
|
||||
created_ids.add(added["tabId"])
|
||||
|
||||
for _ in range(20):
|
||||
original_tabs = browser("group.tabs", {"groupId": gid})
|
||||
if any(tab.get("url") == group_url for tab in original_tabs):
|
||||
break
|
||||
time.sleep(0.1)
|
||||
|
||||
browser("session.save", {"name": session_name})
|
||||
|
||||
original_tabs = browser("group.tabs", {"groupId": gid})
|
||||
@@ -68,7 +76,12 @@ def test_session_load_restores_group_metadata(browser):
|
||||
tabs_after = browser("tabs.list")
|
||||
loaded_ids = {t["id"] for t in tabs_after} - baseline_ids
|
||||
|
||||
restored_groups = []
|
||||
for _ in range(20):
|
||||
restored_groups = browser("group.query", {"search": group_name})
|
||||
if restored_groups:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
assert restored_groups, "Expected saved group to be restored"
|
||||
|
||||
restored = next((g for g in restored_groups if g.get("title") == group_name), None)
|
||||
@@ -95,6 +108,6 @@ def teardown_module(module):
|
||||
"""Clean up test sessions after all tests run."""
|
||||
for name in [SESSION_NAME, SESSION_NAME + "_a", SESSION_NAME + "_b", SESSION_NAME + "_groups"]:
|
||||
try:
|
||||
send_command("session.remove", {"name": name})
|
||||
send_command("session.remove", {"name": name}, profile=TEST_BROWSER_PROFILE)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user