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
lint
Laith Weinbergerbdecd06e3ed2
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex 29ed8a884..dbc738585 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -10,9 +10,6 @@ from browser_use.actor.utils import get_key_infofrom browser_use.browser.events import (ClickCoordinateEvent,ClickElementEvent,- DownloadProgressEvent,- DownloadStartedEvent,- FileDownloadedEvent,GetDropdownOptionsEvent,GoBackEvent,GoForwardEvent,@@ -108,7 +105,6 @@ class DefaultActionWatchdog(BaseWatchdog):# Get the downloads watchdog and register direct callbacksdownloads_watchdog = self.browser_session._downloads_watchdog- import sys; print(f'[DEBUG] downloads_watchdog={downloads_watchdog is not None}', file=sys.stderr) # TEMP DEBUGself.logger.debug(f'[ClickWithDownload] downloads_watchdog={downloads_watchdog is not None}')if downloads_watchdog:self.logger.debug('[ClickWithDownload] Registering download callbacks...')@@ -372,9 +368,7 @@ class DefaultActionWatchdog(BaseWatchdog):self.logger.warning('⚠️ PDF generation failed, falling back to regular click')# Execute click with automatic download detection- click_metadata = await self._execute_click_with_download_detection(- self._click_element_node_impl(element_node)- )+ click_metadata = await self._execute_click_with_download_detection(self._click_element_node_impl(element_node))# Check for validation errorsif isinstance(click_metadata, dict) and 'validation_error' in click_metadata:diff --git a/browser_use/browser/watchdogs/downloads_watchdog.py b/browser_use/browser/watchdogs/downloads_watchdog.pyindex d759a8d55..4baf3a75d 100644--- a/browser_use/browser/watchdogs/downloads_watchdog.py+++ b/browser_use/browser/watchdogs/downloads_watchdog.py@@ -10,7 +10,8 @@ from urllib.parse import urlparseimport anyiofrom bubus import BaseEvent-from cdp_use.cdp.browser import DownloadProgressEvent, DownloadWillBeginEvent+from cdp_use.cdp.browser import DownloadProgressEvent as CDPDownloadProgressEvent+from cdp_use.cdp.browser import DownloadWillBeginEventfrom cdp_use.cdp.network import ResponseReceivedEventfrom cdp_use.cdp.target import SessionID, TargetIDfrom pydantic import PrivateAttr@@ -79,14 +80,18 @@ class DownloadsWatchdog(BaseWatchdog):on_complete: Any | None = None,) -> None:"""Register direct callbacks for download events-+Callbacks called sync from CDP event handlers, so clickhandlers receive download notif without waiting for event bus to process"""- self.logger.debug(f'[DownloadsWatchdog] Registering callbacks: start={on_start is not None}, progress={on_progress is not None}, complete={on_complete is not None}')+ self.logger.debug(+ f'[DownloadsWatchdog] Registering callbacks: start={on_start is not None}, progress={on_progress is not None}, complete={on_complete is not None}'+ )if on_start:self._download_start_callbacks.append(on_start)- self.logger.debug(f'[DownloadsWatchdog] Registered start callback, now have {len(self._download_start_callbacks)} start callbacks')+ self.logger.debug(+ f'[DownloadsWatchdog] Registered start callback, now have {len(self._download_start_callbacks)} start callbacks'+ )if on_progress:self._download_progress_callbacks.append(on_progress)if on_complete:@@ -275,11 +280,11 @@ class DownloadsWatchdog(BaseWatchdog):# Remove from set when donetask.add_done_callback(lambda t: self._cdp_event_tasks.discard(t))- def download_progress_handler(event: DownloadProgressEvent, session_id: SessionID | None) -> None:+ def download_progress_handler(event: CDPDownloadProgressEvent, session_id: SessionID | None) -> None:guid = event.get('guid', '')state = event.get('state', '')- received_bytes = event.get('receivedBytes', 0)- total_bytes = event.get('totalBytes', 0)+ received_bytes = int(event.get('receivedBytes', 0))+ total_bytes = int(event.get('totalBytes', 0))# Call direct callbacks first (for click handlers tracking progress)progress_info = {