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
clear selector map cache after scolling so its recalculated
Nick Sweetingcdfd8b9fcc13
diff --git a/browser_use/browser/default_action_watchdog.py b/browser_use/browser/default_action_watchdog.pyindex 22a6bd20d..28cfc003a 100644--- a/browser_use/browser/default_action_watchdog.py+++ b/browser_use/browser/default_action_watchdog.py@@ -173,6 +173,13 @@ class DefaultActionWatchdog(BaseWatchdog):params={'targetId': self.browser_session.agent_focus.target_id})+ # IMPORTANT: clear the selector map cache even if no navigation has happened!+ # it's calculated based on visible elements, and if we don't clear it, it will be wrong+ self.browser_session._cached_browser_state_summary = None+ self.browser_session._cached_selector_map.clear()+ if self.browser_session._dom_watchdog:+ self.browser_session._dom_watchdog.clear_cache()+# Log successself.logger.info(f'📜 Scrolled {event.direction} by {event.amount} pixels')return None