Skip to content

Conversation

@jay-sahnan
Copy link
Contributor

Add Basic Screenshots Template

Adds a new template demonstrating how to automate screenshot capture during browser automation flows using Stagehand and Browserbase.

Copy link
Member

@Kylejeong2 Kylejeong2 left a comment

Choose a reason for hiding this comment

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

would talk with customer eng/stagehand devs about some best practices for screenshots.

not sure about having a separate screenshot function just for ss where you pass in a filename.

also the TS version with stagehand v3 you can just call page.screenshot( ...params)


# Helper function to take and save a screenshot
# Captures full-page screenshots in JPEG format for documentation and debugging
async def take_screenshot(page, filename: str):
Copy link
Member

Choose a reason for hiding this comment

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

do we want a whole function to save screenshots? can't u specify screenshot storage dir https://docs.stagehand.dev/v3/references/page#param-path

may be weird if you do that for the each ss though

import { writeFileSync, mkdirSync, existsSync } from "fs";
import { join } from "path";
import { Stagehand } from "@browserbasehq/stagehand";
import type { Page } from "playwright";
Copy link
Member

Choose a reason for hiding this comment

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

you can screenshot without the playwright page https://docs.stagehand.dev/v3/references/page#screenshot

"start": "tsx index.ts"
},
"dependencies": {
"@browserbasehq/sdk": "latest",
Copy link
Member

Choose a reason for hiding this comment

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

what is the sdk for?

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