Files
browser-cli/tests/test_page.py
T
daniel156161 9aad012bdc test: expand browser command coverage
- Add mocked Click CLI tests across DOM, cookies, page, storage, perf, navigation, tabs, groups, sessions, and windows commands.
- Cover integration paths for cookies, page info, performance profiles, and web storage commands.
- Extend DOM integration coverage for eval, scrolling, waiting, focus, hover, typing, selection, keyboard, and checkbox interactions.
- Add native host unit coverage for message framing, socket helpers, paging guards, timeouts, and profile alias resolution.
2026-05-20 23:53:56 +02:00

40 lines
1.6 KiB
Python

"""Integration tests for page.info command — require a live browser."""
def test_page_info_returns_required_fields(browser, http_tab):
"""page.info returns title, url, readyState and lang."""
browser("tabs.active", {"tabId": http_tab["id"]})
info = browser("page.info")
assert isinstance(info, dict)
assert "title" in info
assert "url" in info
assert "readyState" in info
assert "lang" in info
def test_page_info_url_matches_active_tab(browser, http_tab):
"""URL reported by page.info matches the tab URL in tabs.list."""
browser("tabs.active", {"tabId": http_tab["id"]})
info = browser("page.info")
assert info is not None
# Active tab URL should match (allow for trailing slash difference)
assert "example.com" in info.get("url", "")
def test_page_info_ready_state_complete(browser, http_tab):
"""A fully loaded page reports readyState == 'complete'."""
browser("tabs.active", {"tabId": http_tab["id"]})
info = browser("page.info")
assert info.get("readyState") == "complete"
def test_page_info_title_non_empty(browser, http_tab):
"""example.com has a non-empty title."""
browser("tabs.active", {"tabId": http_tab["id"]})
info = browser("page.info")
assert isinstance(info.get("title"), str)
assert len(info["title"]) > 0
def test_page_info_meta_is_dict(browser, http_tab):
"""meta field is a dict (may be empty for simple pages)."""
browser("tabs.active", {"tabId": http_tab["id"]})
info = browser("page.info")
meta = info.get("meta")
assert meta is None or isinstance(meta, dict)