Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Update context.py to reload when using CDP remote browser

Vishal Rao3998f278f6cf
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 24f8143b0..cd51765b2 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -216,6 +216,8 @@ class BrowserContext:
def _add_new_page_listener(self, context: PlaywrightBrowserContext):
async def on_page(page: Page):
+ if self.browser.config.cdp_url:
+ await page.reload() # Reload the page to avoid timeout errors
await page.wait_for_load_state()
logger.debug(f'New page opened: {page.url}')
if self.session is not None:
@@ -1138,4 +1140,4 @@ class BrowserContext:
tabs=[],
)
- # endregion
\ No newline at end of file
+ # endregion