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
tweak screenshots to timeout after 10s and full_page=False
Nick Sweeting17f83b205edc
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 97b661bc4..76f806120 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -2453,21 +2453,25 @@ class BrowserSession(BaseModel):pass# 0. Attempt full-page screenshot (sometimes times out for huge pages)- try:- screenshot = await page.screenshot(- full_page=full_page,- scale='css',- timeout=15000,- animations='allow',- caret='initial',- )+ if full_page:+ try:+ screenshot = await asyncio.wait_for(+ page.screenshot(+ full_page=True,+ scale='css',+ timeout=10000,+ animations='allow',+ caret='initial',+ ),+ timeout=15000,+ )- screenshot_b64 = base64.b64encode(screenshot).decode('utf-8')- return screenshot_b64- except Exception as e:- self.logger.error(- f'❌ Failed to take full-page screenshot: {type(e).__name__}: {e} falling back to viewport-only screenshot'- )+ screenshot_b64 = base64.b64encode(screenshot).decode('utf-8')+ return screenshot_b64+ except Exception as e:+ self.logger.warning(+ f'⚠️ Failed to take full-page screenshot after 10s: {type(e).__name__}: {e} trying with height limit instead...'+ )# Fallback method: manually expand the viewport and take a screenshot of the entire viewport