Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

avocardio
Copy link
Collaborator

@avocardio avocardio commented Sep 8, 2025

Currently (I think) theres only one way to take a screenshot (via events):

screenshot_event = browser_session.event_bus.dispatch(ScreenshotEvent(full_page=True))
await screenshot_event 
screenshot_b64 = await screenshot_event.event_result()

This is much easier:

 screenshot_data = await browser_session.take_screenshot(full_page=True)

Also I need this for demos plz.


Summary by cubic

Adds a simple screenshot API to BrowserSession, replacing the event‑bus flow. Supports full-page, region, and element captures, with optional file save and format control.

  • New Features
    • BrowserSession.take_screenshot(path=None, full_page=False, format='png', quality=None, clip=None) returns bytes; supports png/jpeg/webp, JPEG quality, optional clip, and saving to disk.
    • BrowserSession.screenshot_element(selector, path=None, format='png', quality=None) captures a CSS-selected element by auto-computing bounds.
    • CI test verifies viewport and element screenshots return data.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@CLAassistant
Copy link

CLAassistant commented Sep 8, 2025

CLA assistant check
All committers have signed the CLA.

@avocardio avocardio force-pushed the feature/enhanced-screenshot-api branch from 7cfab93 to 3336b9d Compare September 8, 2025 16:14
@sauravpanda sauravpanda merged commit 5f6400d into browser-use:main Sep 8, 2025
120 of 125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants