Skip to content

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

disable screenshot rescaling and only use original viewport if set

Nick Sweetinge7e8f38bdbab
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 8af2b4030..0e7da72c6 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -721,7 +721,7 @@ class BrowserSession(BaseModel):
try:
screenshot = await page.screenshot(
full_page=False,
- scale='css',
+ # scale='css',
timeout=self.browser_profile.default_timeout or 30000,
clip=FloatRect(**clip) if clip else None,
animations='allow',
@@ -2745,7 +2745,7 @@ class BrowserSession(BaseModel):
# )
# 3. Expand the viewport if we are using one
- original_viewport = page.viewport_size
+ original_viewport = page.viewport_size and self.browser_profile.viewport
try:
if original_viewport:
# if we're already using a viewport, temporarily expand it to the desired size for the screenshot