> For the complete documentation index, see [llms.txt](https://docs.testvibe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testvibe.com/quickstart/generate-playwright-code.md).

# Generate Playwright Code

After you create a test, use AI generation to turn the readable test intent into Playwright code.

Generation may take a few minutes. TestVibe will show progress while the agent works.

{% hint style="info" %}
[Playwright](https://playwright.dev/) is the open-source browser automation framework TestVibe generates tests for. Visit [playwright.dev](https://playwright.dev/) to learn more.
{% endhint %}

## Before You Generate

Check that you have:

* a saved test or feature
* a site URL the cloud session can reach
* any variables or secrets your test references, added in Settings → Variables & Secrets

If something is missing, TestVibe may prompt you before generation starts.

## Steps

1. Select the test you created in the Test Suite.
2. Start generation from the test details or generation action.
3. Confirm the site URL and generation options if prompted.
4. Keep the default agent and model unless your team has a reason to change them (Settings → AI Model).
5. Start generation.
6. Watch the generation progress view.
7. Wait for the generation to finish.

When generation succeeds, TestVibe should show generated output and make the test ready to run.

## What Happens During Generation

TestVibe uses your Gherkin feature or test instructions as the source of intent. A cloud agent uses that intent to create Playwright code and supporting output, which is saved to your project. Generation usage is metered in credits.

You may see states such as:

* queued
* setting up
* running
* finalizing
* succeeded
* failed
* cancelled

If generation fails, open the failure details before changing the test. The problem may be a missing variable or secret, an unreachable site, an unclear instruction, or application behavior that did not match the expected result.

## After Generation Succeeds

Review the output enough to confirm that:

* the generated code matches the behavior you intended
* the target page or flow is correct
* the expected result is being checked
* no obvious setup or data requirement is missing

For deeper help, see [Read generated output](/ai-generation/read-generated-output.md).

## Next

Continue to [Run your first test](/quickstart/run-first-test.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.testvibe.com/quickstart/generate-playwright-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
