Skip to content

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

bump cdp-use version

Nick Sweeting1aa486c5346e
diff --git a/browser_use/browser/downloads_watchdog.py b/browser_use/browser/downloads_watchdog.py
index da1e5bfa9..3dcad1ef6 100644
--- a/browser_use/browser/downloads_watchdog.py
+++ b/browser_use/browser/downloads_watchdog.py
@@ -164,7 +164,7 @@ class DownloadsWatchdog(BaseWatchdog):
)
# Register download event handlers
- def download_will_begin_handler(event: DownloadWillBeginEvent, session_id: str | None):
+ async def download_will_begin_handler(event: DownloadWillBeginEvent, session_id: str | None):
self.logger.info(f'[DownloadsWatchdog] Download will begin: {event}')
# Create and track the task
task = asyncio.create_task(self._handle_cdp_download(event, target_id, session_id))
@@ -172,7 +172,7 @@ class DownloadsWatchdog(BaseWatchdog):
# Remove from set when done
task.add_done_callback(lambda t: self._cdp_event_tasks.discard(t))
- def download_progress_handler(event: DownloadProgressEvent, session_id: str | None):
+ async def download_progress_handler(event: DownloadProgressEvent, session_id: str | None):
# Check if download is complete
if event.get('state') == 'completed':
file_path = event.get('filePath')
diff --git a/browser_use/browser/events.py b/browser_use/browser/events.py
index c676b9345..3f3540b67 100644
--- a/browser_use/browser/events.py
+++ b/browser_use/browser/events.py
@@ -154,7 +154,7 @@ class BrowserStateRequestEvent(BaseEvent[BrowserStateSummary]):
"""Request current browser state."""
include_dom: bool = True
- include_screenshot: bool = False
+ include_screenshot: bool = True
cache_clickable_elements_hashes: bool = True
include_recent_events: bool = False
diff --git a/browser_use/browser/popups_watchdog.py b/browser_use/browser/popups_watchdog.py
index 212f81d89..8f7543f1d 100644
--- a/browser_use/browser/popups_watchdog.py
+++ b/browser_use/browser/popups_watchdog.py
@@ -103,7 +103,7 @@ class PopupsWatchdog(BaseWatchdog):
# delay to look more human
await asyncio.sleep(0.25)
assert self.browser_session._cdp_client_root
- self.browser_session._cdp_client_root.register.Page.javascriptDialogClosed(lambda *args: None)
+ # self.browser_session._cdp_client_root.register.Page.javascriptDialogClosed(lambda *args: None)
await asyncio.wait_for(
self.browser_session._cdp_client_root.send.Page.handleJavaScriptDialog(
params={'accept': True},
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index b4556ccdd..11fb03135 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -741,11 +741,13 @@ class BrowserSession(BaseModel):
# Don't use cached state if we need a screenshot but the cached state doesn't have one
if include_screenshot and not self._cached_browser_state_summary.screenshot:
self.logger.debug('⚠️ Cached browser state has no screenshot, fetching fresh state with screenshot')
+ # Fall through to fetch fresh state with screenshot
elif selector_map and len(selector_map) > 0:
self.logger.debug('🔄 Using pre-cached browser state summary for open tab')
return self._cached_browser_state_summary
else:
self.logger.debug('⚠️ Cached browser state has 0 interactive elements, fetching fresh state')
+ # Fall through to fetch fresh state
# Dispatch the event and wait for result
event: BrowserStateRequestEvent = cast(
diff --git a/pyproject.toml b/pyproject.toml
index 87255f8cc..afe8278ba 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,7 +41,7 @@ dependencies = [
"google-auth-oauthlib>=1.2.2",
"mcp>=1.10.1",
"pypdf>=5.7.0",
- "cdp-use>=1.3.5",
+ "cdp-use>=1.4.0",
"markdown-pdf==1.5",
]
# google-api-core: only used for Google LLM APIs