> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdino.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright Test Generation

> Record or describe a browser flow and compile it to a deterministic Playwright spec you can read, run, export, and report to TestDino.

<Warning>
  **Beta.** Test Generation is available to selected customers only. It is not included in any plan, and it is not covered by the TestDino service agreement or support SLA. Behavior and limits can change between releases. Ask for access through [Support](/support).
</Warning>

Test Generation records or describes a browser flow and compiles it to a deterministic Playwright spec. Every step is stored as structured data first, so the same test always compiles to the same TypeScript, and you review real Playwright code rather than a recording.

## Quick Reference

| Way to author                                        | What you do                                       | What the model does                                 |
| :--------------------------------------------------- | :------------------------------------------------ | :-------------------------------------------------- |
| [Record](#record-a-flow)                             | Click through the app in an embedded browser      | Nothing. Steps come from the recorder.              |
| [Edit steps](#edit-steps)                            | Add, reorder, or repick steps in the step editor  | Nothing                                             |
| [Plain-English steps](#write-steps-in-plain-english) | Type `click "Sign in"` style sentences            | Nothing. A fixed grammar parses them.               |
| [AI step, check, and flow](#author-with-ai)          | Describe an action, an assertion, or a whole flow | Picks elements from the live page and returns steps |
| [Browser agent](#author-with-ai)                     | Give a goal and a step budget                     | Observes the page and acts one step per turn        |

AI runs only while you author. The compiled spec and every replay are model-free.

## Record a flow

Recording runs a headless Chromium on the server and streams it into the browser tab. You interact with the page in place. Clicks, typing, navigation, new tabs, and tab closes become steps as you go.

| Recorded as a step            | Detail                                                                       |
| :---------------------------- | :--------------------------------------------------------------------------- |
| Click, fill, select, check    | Target stored as a locator ladder, not a single selector                     |
| Navigation                    | `goto` with the path relative to the environment base URL                    |
| New tab or closed tab         | `switch_tab`, so multi-tab flows replay deterministically                    |
| Assertion                     | Toggle Assert mode, then click an element to add a check                     |
| Iframe and shadow DOM targets | Frame path and composed target captured for Salesforce and other legacy apps |

## Edit steps

Every step is a chip you can edit, reorder, or delete. Repick a target on the live page when the app changes. If/Else steps carry an editable predicate with THEN and ELSE branches. Each editing burst snapshots the test, and the History panel compares and restores versions.

## Write steps in plain English

The plain-English composer parses a fixed grammar into the same step types the recorder produces. No model is involved, so a sentence either parses or the composer tells you which part it did not understand.

```text theme={null}
go to /login
fill Email with "qa@example.com"
fill Password with "{{PASSWORD}}"
click on Sign in
verify Dashboard is visible
```

## Author with AI

AI authoring needs a model configured for the workspace. Without one, the AI controls stay visible and return a disabled state instead of an error.

| Mode          | Input                                              | Output                                                       |
| :------------ | :------------------------------------------------- | :----------------------------------------------------------- |
| AI step       | One sentence describing an action                  | One step with a locator ladder built from the live page      |
| AI check      | One sentence describing an expected state          | One assertion step                                           |
| AI flow       | A paragraph describing a flow                      | An ordered list of steps you review before saving            |
| Browser agent | A goal and a step budget from 1 to 30 (default 12) | Steps recorded as the agent works, one action per model turn |

The agent never writes selectors. Test Generation enumerates the interactive elements on the page, builds a locator ladder for each one, and the model returns only an element index and an action. The result is recorder-grade locators, whichever mode you use.

## Generated code

The compiler is a pure function. The same test, environment, and options produce byte-identical TypeScript. It emits `@playwright/test` code you can read in a pull request.

| Rule                             | How it shows in the spec                                                                                            |
| :------------------------------- | :------------------------------------------------------------------------------------------------------------------ |
| Accessibility-first locators     | `getByRole`, then `getByLabel`, `getByPlaceholder`, `getByText`, `getByTestId`, and CSS as the last rung            |
| Web-first assertions             | `expect(locator).toBeVisible()`, `toHaveText()`, `toHaveValue()` with auto-retry                                    |
| Base URL from the environment    | Paths in steps, `baseURL` in config, no hardcoded hosts                                                             |
| Secrets resolved at compile time | Variables such as `{{PASSWORD}}` come from the environment, never from the test body                                |
| Shared modules                   | Export as `inline` to repeat module steps in place, or `functions` to compile each module once as an async function |

Export any test as a `.spec.ts` file from the test page. Generated code is TypeScript only.

## Run and report

Batch runs compile a suite or an ad-hoc set of tests and run them with `npx playwright test`, with live per-test progress and a Playwright HTML report per run.

| Setting    | Value in batch runs                        |
| :--------- | :----------------------------------------- |
| Browser    | Chromium                                   |
| Workers    | 4, fully parallel                          |
| Retries    | 1, so a pass on retry marks the test flaky |
| Trace      | `on-first-retry`                           |
| Screenshot | `only-on-failure`                          |
| Video      | `retain-on-failure`                        |

Turn on TestDino reporting in project settings with a project API key. Each batch run then uploads its report to TestDino, and the run detail page links to the TestDino test run. Uploads never block the run. Learn how uploads work in [Node.js CLI](/cli/testdino-playwright-nodejs).

## Locator health

When a primary locator fails on replay, the runner tries the next rung of the ladder and records the rescue on that step. Rescued steps show in Locator Health with the rung that resolved. Nothing changes in the test until you promote the working rung, so healing always has a person on the trigger.

## Playwright skill

The [Playwright skill](/ai/playwright-skill) documents the rules coding agents follow when they write Playwright by hand: role-based locators, web-first assertions, `baseURL` in config, traces on first retry, retries in CI. Test Generation applies the same rules through its compiler, so a spec you export reads like one an agent wrote with the skill loaded. Install the skill in your repo when an agent edits or extends exported specs, so the hand-written additions match the generated code.

## Limits

* Chromium only. Batch runs and recording do not use Firefox or WebKit.
* TypeScript only. There is no JavaScript export.
* Specs are downloaded or run in place. Test Generation does not commit to a repository or open pull requests.

<CardGroup cols={2}>
  <Card title="Playwright Skill" icon="masks-theater" href="/ai/playwright-skill">
    Rules and guides for agents writing Playwright by hand
  </Card>

  <Card title="Node.js CLI" icon="terminal" href="/cli/testdino-playwright-nodejs">
    How batch run reports reach TestDino
  </Card>

  <Card title="Test Runs" icon="play" href="/platform/playwright-test-runs">
    Read the uploaded runs in TestDino
  </Card>

  <Card title="Flaky Test Detection" icon="badge-check" href="/guides/playwright-flaky-test-detection">
    What TestDino does with retry-marked tests
  </Card>
</CardGroup>
