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
extra TODO comments
Nick Sweeting8c52b5f46aae
diff --git a/browser_use/browser/events.py b/browser_use/browser/events.pyindex 3b2522cb1..c84f6518d 100644--- a/browser_use/browser/events.py+++ b/browser_use/browser/events.py@@ -41,6 +41,7 @@ class ElementSelectedEvent(BaseEvent[T_EventResultType]):is_visible=data.is_visible,absolute_position=data.absolute_position,# override the circular reference fields in EnhancedDOMTreeNode as they cant be serialized and aren't needed by event handlers+ # only used internally by the DOM service during DOM tree building process, not intended public API usecontent_document=None,shadow_root_type=None,shadow_roots=[],@@ -86,7 +87,7 @@ class NavigateToUrlEvent(BaseEvent[None]):)# existing_tab: PageHandle | None = None # TODO- # limit enforced by bubus, not exposed to LLM:+ # time limits enforced by bubus, not exposed to LLM:event_timeout: float | None = 15.0 # secondsdiff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex f58131516..476b629a4 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -495,7 +495,7 @@ class DefaultActionWatchdog(BaseWatchdog):self.logger.debug('🖱️ Clicked successfully using x,y coordinates')# Return coordinates as dict for metadata- return {"click_x": center_x, "click_y": center_y}+ return {'click_x': center_x, 'click_y': center_y}except Exception as e:self.logger.warning(f'CDP click failed: {type(e).__name__}: {e}')@@ -673,7 +673,7 @@ class DefaultActionWatchdog(BaseWatchdog):# Get element infobackend_node_id = element_node.backend_node_id-+# Track coordinates for metadatainput_coordinates = None@@ -707,7 +707,7 @@ class DefaultActionWatchdog(BaseWatchdog):if bounds.get('width', 0) > 0 and bounds.get('height', 0) > 0:center_x = bounds['x'] + bounds['width'] / 2center_y = bounds['y'] + bounds['height'] / 2- input_coordinates = {"input_x": center_x, "input_y": center_y}+ input_coordinates = {'input_x': center_x, 'input_y': center_y}self.logger.debug(f'📍 Input coordinates: x={center_x:.1f}, y={center_y:.1f}')# Provide helpful warnings for common issues@@ -837,7 +837,7 @@ class DefaultActionWatchdog(BaseWatchdog):)# Small delay between charactersawait asyncio.sleep(0.01)-+# Return coordinates metadata if availablereturn input_coordinates@@ -1293,6 +1293,9 @@ class DefaultActionWatchdog(BaseWatchdog):async def on_ScrollToTextEvent(self, event: ScrollToTextEvent) -> None:"""Handle scroll to text request with CDP. Raises exception if text not found."""++ # TODO: handle looking for text inside cross-origin iframes as well+# Get CDP client and sessioncdp_client = self.browser_session.cdp_clientif self.browser_session.agent_focus is None: