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
tweak get_dropdown_options wording to avoid LLM over-use
Nick Sweeting287a66822c6a
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 4d4642779..24a686cc5 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -407,6 +407,7 @@ class BrowserSession(BaseModel):returntarget_id = None+ tab_index = 0# check if the url is already open in a tab somewhere that we haven't interacted with yet, if so, short-circuit and just switch to ittargets = await self._cdp_get_all_pages()@@ -418,7 +419,6 @@ class BrowserSession(BaseModel):try:# Find or create target for navigation- tab_index = 0self.logger.info(f'[on_NavigateToUrlEvent] Processing new_tab={event.new_tab}')if event.new_tab:@@ -503,15 +503,16 @@ class BrowserSession(BaseModel):# - DOM rebuilding (dom_watchdog)except Exception as e:- self.logger.error(f'Navigation failed: {e}')- self.event_bus.dispatch(+ self.logger.error(f'Navigation failed: {type(e).__name__}: {e}')+ await self.event_bus.dispatch(NavigationCompleteEvent(- tab_index=tab_index if 'tab_index' in locals() else 0,+ tab_index=tab_index,url=event.url,- status=None,- error_message=str(e),+ error_message=f'{type(e).__name__}: {e}',))+ await self.event_bus.dispatch(AgentFocusChangedEvent(tab_index=tab_index, url=event.url))+ raiseasync def on_SwitchTabEvent(self, event: SwitchTabEvent) -> None:"""Handle tab switching - core browser functionality."""diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex f5e75b789..1c32ad810 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -703,7 +703,7 @@ Provide the extracted information in a clear, structured format."""# Dropdown Actions@self.registry.action(- 'Get list of options from any dropdown (<select>, ARIA menus, or custom dropdowns like Semantic UI). Searches target element and up to 4 levels of children to find dropdowns. This only works on dropdown elements, not other input types.',+ 'Get list of option values exposed by a specific dropdown input field. Only works on dropdown-style form elements (<select>, Semantic UI/aria-labeled select, etc.).',param_model=GetDropdownOptionsAction,)async def get_dropdown_options(params: GetDropdownOptionsAction, browser_session: BrowserSession):