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
always bringToFront before/after scroll action to prevent timeout
Nick Sweeting0a3dcc789117
diff --git a/browser_use/browser/default_action_watchdog.py b/browser_use/browser/default_action_watchdog.pyindex af145f4df..56f78b265 100644--- a/browser_use/browser/default_action_watchdog.py+++ b/browser_use/browser/default_action_watchdog.py@@ -147,6 +147,11 @@ class DefaultActionWatchdog(BaseWatchdog):# Positive pixels = scroll down, negative = scroll uppixels = event.amount if event.direction == 'down' else -event.amount+ # CRITICAL: CDP calls time out without this, even if the target is already active+ await self.browser_session.agent_focus.cdp_client.send.Target.activateTarget(+ params={'targetId': self.browser_session.agent_focus.target_id}+ )+# Element-specific scrolling if node is providedif event.node is not None:element_node = event.node@@ -163,6 +168,11 @@ class DefaultActionWatchdog(BaseWatchdog):# Perform target-level scrollawait self._scroll_with_cdp_gesture(pixels)+ # CRITICAL: CDP calls time out without this, even if the target is already active+ await self.browser_session.agent_focus.cdp_client.send.Target.activateTarget(+ params={'targetId': self.browser_session.agent_focus.target_id}+ )+# Log successself.logger.info(f'📜 Scrolled {event.direction} by {event.amount} pixels')return None