# 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.

## Before You Generate

Check that you have:

* a saved test or feature
* a reachable site URL
* required API keys or repository secrets
* repository access through the TestVibe GitHub App

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.
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. The AI agent uses that intent to create Playwright code and supporting output.

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 key, unreachable site, 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
