Skip to content

Conversation

derekmeegan
Copy link
Contributor

why

Currently, using playwright screenshot command is not available when the execution environment is Stagehand. A customer has indicated they would prefer to use Playwright's native screenshot command instead of CDP when using Browserbase as CDP screenshot causes unexpected behavior for their target site.

what changed

  • added a StagehandScreenshotOptions type with useCDP argument added
  • extended page type to accept custom stagehand screeenshot options
  • update screenshot proxy to default useCDP to true if the env is browserbase and use playwright screenshot if false
  • added eval for screenshot with and without cdp

test plan

  • tested and confirmed functionality with eval and external example script (not committed)

Copy link

changeset-bot bot commented Sep 12, 2025

⚠️ No Changeset found

Latest commit: ed3fc53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds a useCDP option to screenshot functionality, allowing users to choose between CDP and Playwright's native screenshot method in Browserbase environments. The implementation properly extends the existing Page interface with a new StagehandScreenshotOptions type that includes the useCDP boolean flag, defaulting to true for Browserbase environments to maintain backward compatibility.

New StagehandScreenshotOptions type: Extends Playwright's PageScreenshotOptions with optional useCDP flag
Enhanced screenshot proxy: Modified screenshot method in StagehandPage to conditionally use CDP based on the useCDP flag and environment
Comprehensive evaluation test: Added screenshot_cdp_toggle.ts to test both CDP and Playwright screenshot modes with various options
Configuration update: Added the new evaluation to the evals config

Confidence score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-structured with proper TypeScript types, maintains backward compatibility by defaulting useCDP to true for Browserbase environments, includes comprehensive testing, and follows existing patterns in the codebase. The changes are focused and don't introduce breaking changes.
  • No files require special attention

4 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@miguelg719
Copy link
Collaborator

changeset and gtg @derekmeegan

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.

2 participants