Skip to content

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

Change error message for dropdown

Magnus Müller2613e54b5f50
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.py
index d0034dcec..263420c5e 100644
--- a/browser_use/browser/watchdogs/default_action_watchdog.py
+++ b/browser_use/browser/watchdogs/default_action_watchdog.py
@@ -1980,7 +1980,12 @@ class DefaultActionWatchdog(BaseWatchdog):
if not dropdown_data.get('options'):
msg = f'No options found in dropdown at index {index_for_logging}'
- raise BrowserError(message=msg, long_term_memory=msg)
+ return {
+ 'error': msg,
+ 'short_term_memory': msg,
+ 'long_term_memory': msg,
+ 'element_index': str(index_for_logging),
+ }
# Format options for display
formatted_options = []
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 0a660408f..240912ef6 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -320,6 +320,7 @@ class Tools(Generic[Context]):
logger.error(
f'Failed to get dropdown options as shortcut during click_element_by_index on dropdown: {type(dropdown_error).__name__}: {dropdown_error}'
)
+ return ActionResult(error='Can not click on select elements.')
return handle_browser_error(e)
except Exception as e: