Skip to main content
The get_screenshot method captures a screenshot of the current browser window and returns it as base64-encoded image data along with metadata. Unlike asking Agent.run() to take a screenshot and save it to disk, this method returns the screenshot data programmatically.
This method returns screenshot data directly in your code rather than saving it to disk. If you need screenshots saved automatically to your Downloads folder, use Agent.run() with a prompt like “take a screenshot of this page” instead.

Method Signature

async def get_screenshot(
    self,
    *,
    timeout: int | None = None,
) -> GetScreenshotResponse

Parameters

timeout
int | None
default:"None"
Maximum time in seconds to wait for the screenshot capture to complete. If None, uses the default system timeout.
timeout=30     # Wait up to 30 seconds
timeout=None   # Use default timeout

Return Value

Returns a GetScreenshotResponse object with the following structure:
base64_content
str
required
The screenshot image encoded as a base64 string. This can be decoded and saved to a file, displayed, or processed programmatically.
name
str
required
A suggested filename for the screenshot, typically in a format like “Screenshot 2026-01-14 at 10.54.54 AM”.
mime_type
str
required
The MIME type of the image format (e.g., “image/png”, “image/jpeg”).
timestamp
str
required
ISO 8601 formatted timestamp indicating when the screenshot was captured.

Example

import asyncio
import base64

from narada import Agent, BrowserEnvironment

async def main():
    env = BrowserEnvironment()
    agent = Agent(environment=env)

    try:
        # Navigate to a page
        await agent.go_to_url(url="https://example.com")

        # Capture a screenshot
        response = await agent.get_screenshot()

        # Decode and save the screenshot
        image_data = base64.b64decode(response.base64_content)
        extension = response.mime_type.split('/')[1]  # "png" or "jpeg"
        filename = f"{response.name}.{extension}"

        with open(filename, "wb") as f:
            f.write(image_data)

        print(f"Screenshot saved as {filename}")
        print(f"Captured at: {response.timestamp}")
    finally:
        await env.close()

if __name__ == "__main__":
    asyncio.run(main())