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
use raw channel directly for cdp
Nick Sweeting7f4a3017c461
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 2e22ba5f0..af6c0a482 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2654,10 +2654,7 @@ class BrowserSession(BaseModel):# Take the screenshot using CDP# https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot# Use the internal _channel.send method to bypass some of the async wrapper issues- if hasattr(cdp_session, '_channel'):- result = await cdp_session._channel.send('send', None, {'method': 'Page.captureScreenshot', 'params': cdp_params})- else:- result = await cdp_session.send('Page.captureScreenshot', cdp_params)+ result = await cdp_session._channel.send('send', None, {'method': 'Page.captureScreenshot', 'params': cdp_params})# The result already contains base64 encoded database64_screenshot = result.get('data')@@ -2677,11 +2674,7 @@ class BrowserSession(BaseModel):# Clean up CDP sessionif cdp_session:try:- # Use internal method if available to ensure proper cleanup- if hasattr(cdp_session, '_channel') and hasattr(cdp_session._channel, 'send'):- await cdp_session._channel.send('detach', None, {})- else:- await cdp_session.detach()+ await cdp_session.detach()except Exception:# Ignore all exceptions during cleanuppass