feat(sdk): improve Python SDK ergonomics
Testing / remote-protocol-compat (0.9.3) (push) Successful in 42s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 45s
Testing / test (push) Successful in 42s

- Position browser-cli as a CLI plus Python SDK in docs and package metadata.
- Add public target properties and a raw command escape hatch for unsupported commands.
- Add convenience helpers for opening, finding, closing, and accessing tabs.
- Add plural group aliases and a wait_for_selector DOM convenience alias.
- Extend bound Tab objects with screenshot, pin, refresh, load wait, and URL watch helpers.
- Preserve remote auth key configuration when binding remote Tab and Group objects.
- Bump project and extension versions to 0.9.9 and cover SDK additions with tests.
This commit is contained in:
2026-05-19 20:12:16 +02:00
parent eaa1469143
commit e1e4adbb25
7 changed files with 364 additions and 17 deletions
+24
View File
@@ -95,6 +95,30 @@ class Tab:
"""Return the full HTML source of this tab."""
return self._b()._cmd("tabs.html", {"tabId": self.id})
def screenshot(self, *, format: str = "png", quality: int | None = None) -> str:
"""Capture this tab's visible area. Returns a base64 data URL."""
return self._b().tabs_screenshot(self.id, format=format, quality=quality)
def pin(self) -> None:
"""Pin this tab."""
self._b()._cmd("tabs.pin", {"tabId": self.id})
def unpin(self) -> None:
"""Unpin this tab."""
self._b()._cmd("tabs.unpin", {"tabId": self.id})
def refresh(self) -> Tab:
"""Return a fresh snapshot of this tab."""
return self._b().tabs_status(self.id)
def wait_for_load(self, *, timeout: float = 30.0, ready_state: str = "complete") -> Tab:
"""Wait until this tab reaches the requested readyState."""
return self._b().wait_for_load(self.id, timeout=timeout, ready_state=ready_state)
def watch_url(self, pattern: str, *, timeout: float = 30.0) -> Tab:
"""Wait until this tab's URL matches regex *pattern*."""
return self._b().tabs_watch_url(pattern, tab_id=self.id, timeout=timeout)
def open(self, url: str, *, background: bool = False) -> None:
"""Navigate this tab to *url* in place."""
self._b().navigate_tab(self.id, url)