Skip to content

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

Fixed multiact cache

Magnus Mülleraa45460617f6
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 4311769ed..0cecccf15 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1486,8 +1486,12 @@ class Agent(Generic[Context, AgentStructuredOutput]):
results: list[ActionResult] = []
assert self.browser_session is not None, 'BrowserSession is not set up'
- cached_selector_map = await self.browser_session.get_selector_map()
- cached_element_hashes = {hash(e) for e in cached_selector_map.values()}
+ try:
+ cached_selector_map = self.browser_session._cached_browser_state_summary.dom_state.selector_map
+ cached_element_hashes = {hash(e) for e in cached_selector_map.values()}
+ except Exception as e:
+ self.logger.error(f'Error getting cached selector map: {e}')
+ cached_element_hashes = set()
# await self.browser_session.remove_highlights()
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 23c6faaae..75e27f91f 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -254,64 +254,12 @@ class Controller(Generic[Context]):
# Re-raise with more context
raise ValueError(f'Failed to input text into element {params.index}: {e}') from e
- # AUTO-ENTER for search fields: Automatically press Enter for search inputs
- should_auto_enter = False
-
- # Check if this is a search field based on element attributes
- if node.attributes:
- # Check for search-related attributes
- search_indicators = {'search', 'query', 'find', 'lookup', 'searchbox', 'search-input'}
-
- # Check input type
- input_type = node.attributes.get('type', '').lower()
- if input_type == 'search':
- should_auto_enter = True
-
- # Check class names
- class_list = node.attributes.get('class', '').lower()
- if any(indicator in class_list for indicator in search_indicators):
- should_auto_enter = True
-
- # Check id
- element_id = node.attributes.get('id', '').lower()
- if any(indicator in element_id for indicator in search_indicators):
- should_auto_enter = True
-
- # Check placeholder text
- placeholder = node.attributes.get('placeholder', '').lower()
- if any(indicator in placeholder for indicator in search_indicators):
- should_auto_enter = True
-
- # Check aria-label
- aria_label = node.attributes.get('aria-label', '').lower()
- if any(indicator in aria_label for indicator in search_indicators):
- should_auto_enter = True
-
- # Auto-press Enter for search fields
- if should_auto_enter:
- try:
- logger.info('🔍 Detected search field, auto-pressing Enter after input')
- enter_event = browser_session.event_bus.dispatch(SendKeysEvent(keys='Enter'))
- await enter_event
- except Exception as e:
- logger.warning(f'Failed to auto-press Enter: {e}')
- # Don't fail the entire action if Enter fails
-
- if not has_sensitive_data:
- msg = f'⌨️ Input {params.text} into index {params.index}'
- if should_auto_enter:
- msg += ' (+ Enter)'
- else:
- msg = f'⌨️ Input sensitive data into index {params.index}'
- if should_auto_enter:
- msg += ' (+ Enter)'
-
+ msg = f"Input '{params.text}' into element {params.index}."
logger.info(msg)
return ActionResult(
extracted_content=msg,
include_in_memory=True,
- long_term_memory=f"Input '{params.text}' into element {params.index}."
- + (' Pressed Enter automatically.' if should_auto_enter else ''),
+ long_term_memory=f"Input '{params.text}' into element {params.index}.",
)
# @self.registry.action('Upload file to interactive element with file path', param_model=UploadFileAction)