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
refactor: streamline event handling in BrowserSession
reformedotb741c429d7b7
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 6aed1e052..443fdba96 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -805,15 +805,15 @@ class BrowserSession(BaseModel):if event_loader_id and navigation_id and event_loader_id != navigation_id:continue- if event_name == 'networkIdle':- duration_ms = (asyncio.get_event_loop().time() - nav_start_time) * 1000- self.logger.debug(f'✅ Page ready for {url} (networkIdle, {duration_ms:.0f}ms)')- return-- elif event_name == 'load':- duration_ms = (asyncio.get_event_loop().time() - nav_start_time) * 1000- self.logger.debug(f'✅ Page ready for {url} (load, {duration_ms:.0f}ms)')- return+ if event_name == 'networkIdle':+ duration_ms = (asyncio.get_event_loop().time() - nav_start_time) * 1000+ self.logger.debug(f'✅ Page ready for {url} (networkIdle, {duration_ms:.0f}ms)')+ return++ elif event_name == 'load':+ duration_ms = (asyncio.get_event_loop().time() - nav_start_time) * 1000+ self.logger.debug(f'✅ Page ready for {url} (load, {duration_ms:.0f}ms)')+ returnexcept Exception as e:self.logger.debug(f'Error polling lifecycle events: {e}')