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
Update outdated function names
Magnus Müllerb53a7c116a6f
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.pyindex b8abcfc3f..a8397b957 100644--- a/browser_use/agent/message_manager/service.py+++ b/browser_use/agent/message_manager/service.py@@ -318,7 +318,7 @@ class MessageManager:break# Handle different use_vision modes:- # - "auto": Only include screenshot if explicitly requested by action (e.g., take_screenshot)+ # - "auto": Only include screenshot if explicitly requested by action (e.g., screenshot)# - True: Always include screenshot# - False: Never include screenshotinclude_screenshot = Falsediff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.pyindex 2ea6cfa0d..879a8f35c 100644--- a/browser_use/agent/prompts.py+++ b/browser_use/agent/prompts.py@@ -265,7 +265,7 @@ class AgentMessagePrompt:# Check if current page is a PDF viewer and add appropriate messagepdf_message = ''if self.browser_state.is_pdf_viewer:- pdf_message = 'PDF viewer cannot be rendered. In this page, DO NOT use the extract_structured_data action as PDF content cannot be rendered. '+ pdf_message = 'PDF viewer cannot be rendered. In this page, DO NOT use the extract action as PDF content cannot be rendered. 'pdf_message += 'Use the read_file action on the downloaded PDF in available_file_paths to read the full text content or scroll in the page to see images/figures if needed.\n\n'# Add recent events if available and requesteddiff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex 4868daaa8..5ac880632 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -255,8 +255,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):elif controller is not None:self.tools = controllerelse:- # Exclude take_screenshot tool when use_vision=False- exclude_actions = ['take_screenshot'] if use_vision is False else []+ # Exclude screenshot tool when use_vision=False+ exclude_actions = ['screenshot'] if use_vision is False else []self.tools = Tools(exclude_actions=exclude_actions, display_files_in_done_text=display_files_in_done_text)# Structured outputdiff --git a/browser_use/browser/events.py b/browser_use/browser/events.pyindex a89d9412c..397140f49 100644--- a/browser_use/browser/events.py+++ b/browser_use/browser/events.py@@ -130,7 +130,7 @@ class ClickElementEvent(ElementSelectedEvent[dict[str, Any] | None]):button: Literal['left', 'right', 'middle'] = 'left'while_holding_ctrl: bool = Field(default=False,- description='Set True to open any link clicked in a new tab in the background, can use switch_tab(tab_id=None) after to focus it',+ description='Set True to open any link clicked in a new tab in the background, can use switch(tab_id=None) after to focus it',)# click_count: int = 1 # TODO# expect_download: bool = False # moved to downloads_watchdog.pydiff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex ee7048988..5167307f6 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -103,7 +103,7 @@ class DefaultActionWatchdog(BaseWatchdog):# so we need to switch to the new tab to make the agent aware of the surprise new tab that was opened.# when while_holding_ctrl=True we dont actually want to switch to it,# we should match human expectations of ctrl+click which opens in the background,- # so in multi_act it usually already sends [click_element_by_index(123, while_holding_ctrl=True), switch_tab(tab_id=None)] anyway+ # so in multi_act it usually already sends [click_element_by_index(123, while_holding_ctrl=True), switch(tab_id=None)] anywayfrom browser_use.browser.events import SwitchTabEventnew_target_id = new_target_ids.pop()@@ -258,7 +258,7 @@ class DefaultActionWatchdog(BaseWatchdog):element_type = element_node.attributes.get('type', '').lower() if element_node.attributes else ''if tag_name == 'select':- msg = f'Cannot click on <select> elements. Use get_dropdown_options(index={element_node.element_index}) action instead.'+ msg = f'Cannot click on <select> elements. Use dropdown_options(index={element_node.element_index}) action instead.'self.logger.warning(msg)raise BrowserError(message=msg,@@ -2001,7 +2001,7 @@ class DefaultActionWatchdog(BaseWatchdog):msg = f'Found {dropdown_type} dropdown ({element_info}):\n' + '\n'.join(formatted_options)else:msg = f'Found {dropdown_type} dropdown in {source_info} ({element_info}):\n' + '\n'.join(formatted_options)- msg += f'\n\nUse the exact text or value string (without quotes) in select_dropdown_option(index={index_for_logging}, text=...)'+ msg += f'\n\nUse the exact text or value string (without quotes) in select_dropdown(index={index_for_logging}, text=...)'if source_info == 'target':self.logger.info(f'📋 Found {len(dropdown_data["options"])} dropdown options for index {index_for_logging}')diff --git a/browser_use/mcp/server.py b/browser_use/mcp/server.pyindex 1074f9329..63d241c6c 100644--- a/browser_use/mcp/server.py+++ b/browser_use/mcp/server.py@@ -811,7 +811,7 @@ class BrowserUseServer:state = await self.browser_session.get_browser_state_summary()- # Use the extract_structured_data action+ # Use the extract action# Create a dynamic action model that matches the tools's expectationsfrom pydantic import create_model@@ -819,13 +819,13 @@ class BrowserUseServer:ExtractAction = create_model('ExtractAction',__base__=ActionModel,- extract_structured_data=dict[str, Any],+ extract=dict[str, Any],)# Use model_validate because Pyright does not understand the dynamic modelaction = ExtractAction.model_validate({- 'extract_structured_data': {'query': query, 'extract_links': extract_links},+ 'extract': {'query': query, 'extract_links': extract_links},})action_result = await self.tools.act(diff --git a/browser_use/tools/registry/service.py b/browser_use/tools/registry/service.pyindex 33bbd0342..f70ae6f2d 100644--- a/browser_use/tools/registry/service.py+++ b/browser_use/tools/registry/service.py@@ -350,12 +350,12 @@ class Registry(Generic[Context]):'browser_session': browser_session,'page_extraction_llm': page_extraction_llm,'available_file_paths': available_file_paths,- 'has_sensitive_data': action_name == 'input_text' and bool(sensitive_data),+ 'has_sensitive_data': action_name == 'input' and bool(sensitive_data),'file_system': file_system,}- # Only pass sensitive_data to actions that explicitly need it (input_text)- if action_name == 'input_text':+ # Only pass sensitive_data to actions that explicitly need it (input)+ if action_name == 'input':special_context['sensitive_data'] = sensitive_data# Add CDP-related parameters if browser_session is availablediff --git a/tests/ci/test_browser_event_GetDropdownOptionsEvent.py b/tests/ci/test_browser_event_GetDropdownOptionsEvent.pyindex 078410350..2942192f6 100644--- a/tests/ci/test_browser_event_GetDropdownOptionsEvent.py+++ b/tests/ci/test_browser_event_GetDropdownOptionsEvent.py@@ -319,7 +319,7 @@ class TestGetDropdownOptionsEvent:assert option in result.extracted_content, f"Option '{option}' not found in result content"# Verify instruction is included- assert 'Use the exact text string' in result.extracted_content and 'select_dropdown_option' in result.extracted_content+ assert 'Use the exact text string' in result.extracted_content and 'select_dropdown' in result.extracted_content# Also test direct event dispatchnode = await browser_session.get_element_by_index(dropdown_index)diff --git a/tests/ci/test_browser_event_GetDropdownOptionsEvent_aria_menus.py b/tests/ci/test_browser_event_GetDropdownOptionsEvent_aria_menus.pyindex f74e656ca..98e120a3f 100644--- a/tests/ci/test_browser_event_GetDropdownOptionsEvent_aria_menus.py+++ b/tests/ci/test_browser_event_GetDropdownOptionsEvent_aria_menus.py@@ -212,8 +212,8 @@ class TestARIAMenuDropdown:for option in expected_options:assert option in result.extracted_content, f"Option '{option}' not found in result content"- # Verify the instruction for using the text in select_dropdown_option is included- assert 'Use the exact text string in select_dropdown_option' in result.extracted_content+ # Verify the instruction for using the text in select_dropdown is included+ assert 'Use the exact text string in select_dropdown' in result.extracted_content@pytest.mark.skip(reason='TODO: fix')async def test_select_dropdown_option_with_aria_menu(self, tools, browser_session: BrowserSession, base_url):@@ -347,4 +347,4 @@ class TestARIAMenuDropdown:assert result.extracted_content is not None# The action should return some menu options- assert 'Use the exact text string in select_dropdown_option' in result.extracted_content+ assert 'Use the exact text string in select_dropdown' in result.extracted_contentdiff --git a/tests/ci/test_tools.py b/tests/ci/test_tools.pyindex 8586ef410..d2dae1c6e 100644--- a/tests/ci/test_tools.py+++ b/tests/ci/test_tools.py@@ -454,10 +454,10 @@ class TestToolsIntegration:for option in expected_options[1:]: # Skip the placeholder optionassert option['text'] in result.extracted_content, f"Option '{option['text']}' not found in result content"- # Verify the instruction for using the text in select_dropdown_option is included+ # Verify the instruction for using the text in select_dropdown is includedassert ('Use the exact text or value string' in result.extracted_content- and 'select_dropdown_option' in result.extracted_content+ and 'select_dropdown' in result.extracted_content)# Verify the actual dropdown options in the DOM using CDP