Skip to content
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

Add playwright/cypress/puppeteer code dumping #419

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

christopherhwood
Copy link

why

This adds support for a popular request to be able to dump the stagehand actions taken during a session as playwright code (and adds support for outputting as cypress or puppeteer + either typescript or python as well)

what changed

Added a new ActionRecorder which functions just like a cache except it resets state every time it is initialized (to try to only hold the state from a single session).

The actions from this cache are then converted into playwright code via some hard-coded rules in a newly added testCodeGenerator.ts file.

If the user requests for cypress or puppeteer then we invoke a call to the LLM to convert the playwright code into the other test format.

test plan

Added a new example 2048_recorder.ts. It functions the same as the original 2048 example, except the game loop only loops once, the recorder is enabled, the original code to invoke a playwright function that does a keypress is replaced with a call to stagehand.act, and at the end of the example we dump the playwright code in typescript to the console.

Copy link

changeset-bot bot commented Jan 21, 2025

⚠️ No Changeset found

Latest commit: 0253e1b

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@kamath
Copy link
Contributor

kamath commented Jan 21, 2025

boom!!! thanks so much for this, will take a look shortly

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