Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
ensure session is always initialized when getting current page
Nick Sweetinga75fd48b77c5
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 62a4d5e97..ed4805a57 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -694,6 +694,9 @@ class BrowserSession(BaseModel):async def get_current_page(self) -> Page:"""Get the current page + ensure it's not None / closed"""+ if not self.initialized:+ await self.start()+# get-or-create the browser_context if it's not already set upif not self.browser_context:await self.start()