-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add playwright screen recording example #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 9ee5687 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Greptile OverviewGreptile SummaryAdded a comprehensive example demonstrating how to use Playwright's video recording feature with Stagehand v3, addressing user confusion about video recording after migrating from v2.5. The example shows the complete workflow: connecting to the Stagehand browser via CDP, creating a Playwright context with video recording enabled, performing Stagehand operations ( Key changes:
Issues found:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Stagehand
participant Chromium
participant Browser
participant Context
participant Page
participant FileSystem
User->>Stagehand: new Stagehand({env: "LOCAL"})
User->>Stagehand: init()
Stagehand->>Browser: Launch browser session
User->>Chromium: connectOverCDP(connectURL)
Chromium->>Browser: Connect via CDP
Browser-->>Chromium: Browser instance
User->>FileSystem: mkdir(videoDir, {recursive: true})
FileSystem-->>User: Directory created
User->>Browser: newContext({recordVideo: {...}})
Browser->>Context: Create context with video recording
Context-->>User: Context instance
User->>Context: newPage()
Context->>Page: Create new page
Page-->>User: Page instance
User->>Page: goto(url)
Page-->>User: Page loaded
User->>Stagehand: act('click the introduction div')
Stagehand->>Page: Perform action
Page-->>Stagehand: Action completed
User->>Stagehand: extract('list primitives', schema, {page})
Stagehand->>Page: Extract data
Page-->>Stagehand: Extracted data
Stagehand-->>User: {primitives: [...]}
User->>Page: video()
Page-->>User: Video handle
User->>Context: close()
Context->>FileSystem: Save video file
FileSystem-->>Context: Video saved
Context-->>User: Context closed
User->>User: video.path()
User->>User: Log video path
User->>Stagehand: close()
Stagehand->>Browser: Close browser
Browser-->>Stagehand: Closed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
| waitUntil: "domcontentloaded", | ||
| }); | ||
|
|
||
| await stagehand.act("click the introduction div in the first steps section"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: incorrect indentation breaks code formatting
| await stagehand.act("click the introduction div in the first steps section"); | |
| await stagehand.act('click the introduction div in the first steps section') |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/examples/v3/recordVideo.ts
Line: 27:27
Comment:
**syntax:** incorrect indentation breaks code formatting
```suggestion
await stagehand.act('click the introduction div in the first steps section')
```
How can I resolve this? If you propose a fix, please make it concise.This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/[email protected] ### Patch Changes - [#1273](#1273) [`ab51232`](ab51232) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: trigger shadow root rerender in OOPIFs by cloning & replacing instead of reloading - [#1268](#1268) [`c76ade0`](c76ade0) Thanks [@tkattkat](https://github.com/tkattkat)! - Expose reasoning, and cached input tokens in stagehand metrics - [#1267](#1267) [`ffb5e5d`](ffb5e5d) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: file uploads failing on Browserbase - [#1269](#1269) [`772e735`](772e735) Thanks [@tkattkat](https://github.com/tkattkat)! - Add example using playwright screen recording ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies \[[`ab51232`](ab51232), [`c76ade0`](c76ade0), [`ffb5e5d`](ffb5e5d), [`772e735`](772e735)]: - @browserbasehq/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/[email protected] ### Patch Changes - [#1273](browserbase/stagehand#1273) [`ab51232`](browserbase/stagehand@ab51232) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: trigger shadow root rerender in OOPIFs by cloning & replacing instead of reloading - [#1268](browserbase/stagehand#1268) [`c76ade0`](browserbase/stagehand@c76ade0) Thanks [@tkattkat](https://github.com/tkattkat)! - Expose reasoning, and cached input tokens in stagehand metrics - [#1267](browserbase/stagehand#1267) [`ffb5e5d`](browserbase/stagehand@ffb5e5d) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: file uploads failing on Browserbase - [#1269](browserbase/stagehand#1269) [`772e735`](browserbase/stagehand@772e735) Thanks [@tkattkat](https://github.com/tkattkat)! - Add example using playwright screen recording ## @browserbasehq/[email protected] ### Patch Changes - Updated dependencies \[[`ab51232`](browserbase/stagehand@ab51232), [`c76ade0`](browserbase/stagehand@c76ade0), [`ffb5e5d`](browserbase/stagehand@ffb5e5d), [`772e735`](browserbase/stagehand@772e735)]: - @browserbasehq/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
why
We have users who are unsure how to record videos of the page in v3
what changed
added example of using playwright in v3 to record videos
test plan
tested locally
addresses #1252