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
Update screenshot handling for empty pages in BrowserSession
mertunsall3263e6751ffc
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 1d5589c93..95100967e 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -3564,10 +3564,10 @@ class BrowserSession(BaseModel):self.logger.warning(f'▫️ Sending LLM 1px placeholder instead of real screenshot of: {_log_pretty_url(page.url)} (page empty)')- # not an exception because there's no point in retrying if we hit this, its always pointless to screenshot about:blank- # raise ValueError('Refusing to take unneeded screenshot of empty new tab page')- # return a 1px*1px white png to avoid wasting tokens- return 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII='+ # Not an exception because there's no point in retrying if we hit this, its always pointless to screenshot about:blank+ # Originally returned a 1x1 white PNG to avoid wasting tokens, but groq LLaMa models do not accept this+ # So we return None instead, which the LLM can handle more reliably+ return None# Always bring page to front before rendering, otherwise it crashes in some cases, not sure whytry: