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
Better error message for llm
Magnus Müllerc153a9bed85f
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 5adb55f2b..f652aa6a2 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2075,7 +2075,8 @@ class BrowserSession(BaseModel):element_handle = await self.get_locate_element(element_node)if element_handle is None:- raise Exception(f'Element: {repr(element_node)} not found')+ self.logger.debug(f'Element: {repr(element_node)} not found')+ raise Exception('Element not found')async def perform_click(click_func):"""Performs the actual click, handling both download and navigation scenarios."""@@ -2169,7 +2170,7 @@ class BrowserSession(BaseModel):except URLNotAllowedError as e:raise eexcept Exception as e:- raise Exception(f'Failed to click element: {repr(element_node)}. Error: {str(e)}')+ raise Exception(f'Failed to click element. Error: {str(e)}')@time_execution_async('--get_tabs_info')@retry(timeout=6, retries=1)diff --git a/browser_use/dom/service.py b/browser_use/dom/service.pyindex dc059732a..1bc0000a3 100644--- a/browser_use/dom/service.py+++ b/browser_use/dom/service.py@@ -15,6 +15,7 @@ from browser_use.dom.views import (SelectorMap,ViewportInfo,)+from browser_use.observability import observe_debugfrom browser_use.utils import is_new_tab_page, time_execution_async# @dataclass@@ -34,6 +35,7 @@ class DomService:self.js_code = resources.files('browser_use.dom.dom_tree').joinpath('index.js').read_text()# region - Clickable elements+ @observe_debug(ignore_input=True, ignore_output=True, name='get_clickable_elements')@time_execution_async('--get_clickable_elements')async def get_clickable_elements(self,