SDK: various small improvements (#4170)

This commit is contained in:
Stanislav Novosad
2025-12-02 14:18:43 -07:00
committed by GitHub
parent c810096bf3
commit 3e46430802
3 changed files with 81 additions and 7 deletions

View File

@@ -105,3 +105,25 @@ class SkyvernBrowser(BrowserContext):
async def _create_skyvern_page(self, page: Page) -> SkyvernBrowserPage:
return SkyvernBrowserPage(self, page)
async def close(self, **kwargs: Any) -> None:
"""Close the browser and optionally close the browser session.
This method closes the browser context. If the browser is associated with a
cloud browser session (has a browser_session_id), it will also close the
browser session via the API, marking it as completed.
Args:
**kwargs: Arguments passed to the underlying BrowserContext.close() method.
Example:
```python
browser = await skyvern.launch_cloud_browser()
# ... use the browser ...
await browser.close() # Closes both browser and cloud session
```
"""
await self._browser_context.close(**kwargs)
if self._browser_session_id:
await self._skyvern.close_browser_session(self._browser_session_id)