Test Scripts
A test script is runnable Java automation code that TestFlair writes for one of your test cases, using Selenium or Playwright. The AI first walks through the test case in a real browser against your application, then writes code that repeats exactly what it verified.
- Who can generate Project Admin, QA Manager, Tester (and workspace Owners and Coordinators)
- Costs Flairs, per script generated. The dialog shows an estimate and your balance before you confirm
- Where Generate from the Test Cases tab; manage the results on the Test Scripts tab
- You need A test case with a URL, the address of the page the test starts on
How a script is made
- YouPick test cases and a framework
- Open a cloud browser at the test case URL
- If anyReplay preconditions
- AIAI explores your app step by step
- RecordingRecording of verified steps
- AIWrite Java code that mirrors it
- AICompile check and automatic fixes
- OutcomeScript ready to run
- Exploration. TestFlair opens a browser in the cloud at the test case's URL. The AI performs the test case's steps one by one against your application, with your test data, and checks each step's expected result. When it takes a wrong turn it goes back to the last step that passed and tries again, so detours don't end up in your script.
- Recording. As it works, TestFlair records the exact interactions that passed: which element was clicked or typed into, the values entered, the checks made and the page the test ends on. Values that come from your test data stay linked to that test data rather than being copied into the code.
- Code generation. The script is written to perform exactly the recorded actions and assert exactly the recorded checks, using element locators that were proven to work during the exploration.
- Compile check. The generated code is compiled, and compilation errors are fixed automatically before the script is marked complete.
Why the recording matters
Because the script mirrors a walk-through that actually succeeded against your application, it is far less likely to click the wrong element, skip a step or assert something your app never shows. You don't need to do anything to turn recording on; it happens on every generation.
The recording is also what makes test case preconditions work. When a test case starts after another one (for example "Log in" before "Edit profile"), TestFlair replays the precondition's recording to reach the right starting point before exploring the dependent case. A precondition can only be used once its own script was generated with every step passing. If it can't, the test case shows why, for example:
| Message | What to do |
|---|---|
| …has no test script yet | Generate the precondition's script first. |
| …last script generation did not pass every step | Regenerate the precondition's script. |
| …recording uses an action that cannot be replayed | The precondition used something replay can't repeat (such as a file upload). Regenerate it, or change its steps. |
| …recording failed its last replay | The application changed since it was recorded. Regenerate the precondition's script. |
| …was edited after its script was generated | Regenerate the precondition's script so the recording matches the steps. |
If an exploration doesn't pass every step, TestFlair still writes a script from what the AI did. That script is worth reviewing before you rely on it, and the test case can't serve as a precondition until it is regenerated.
Generating scripts

Scripts are generated from the Test Cases tab. Each test case needs a URL; use Add URL on the test case (or on several selected test cases) to set one.
- Choose test cases Select test cases in the table and click Generate test scripts in the selection bar, or use the Generate test scripts icon on a single row. The Generate test scripts button in the page header generates for the project's test cases when nothing is selected.
- Pick language and framework In How would you like to generate your script?, the language is Java and you choose Selenium or Playwright. TestFlair preselects the framework you used last time (Playwright the first time).
- Check the cost The dialog shows the estimated cost for the number of scripts and your current Flair balance.
- Confirm Click Generate Test Script. The cards appear on the Test Scripts tab straight away with a Generating... tag.
You can also generate from a test case's drawer with Generate Test Script.
A test case runs in the same browser as its preconditions, so they must use the same framework. If a selected test case has a precondition whose script was built with Selenium, the picker shows Locked to Selenium and the other option is disabled. If test cases that depend on the selection use the other framework, the picker warns that they will be blocked until they are regenerated too.
While a test case's script is generating, you can't edit, delete or regenerate that test case; its actions show Test script generation in progress.
Languages and frameworks
| Choice | Options |
|---|---|
| Language | Java |
| Framework | Selenium or Playwright |
Both frameworks run in a Chromium-based browser. Scripts generated from an AI editor through the MCP server are also Java.
Following generation

Generation takes a couple of minutes per script and runs in the background, so you can keep working.
- Progress indicator. A panel in the corner of the app lists your running jobs (script generation, executions and bug generation) with a ring showing how many have finished, for example 2 of 5 items completed. Click an entry to jump to it. Finished entries stay until you dismiss them, and the panel only shows jobs from the workspace you are in.
- Batches. Scripts generated together are grouped under a Batch header with a done count (for example 3/4) until all of them finish.
- Generation details. Click a generating card (or choose Generation details from its menu) to open the live view:
| Tab | Shows |
|---|---|
| Stream | The live cloud browser next to the Action Log (every action the AI took, with a tick or a cross) and the Generation Logs. See Watching the AI Explore. |
| Logs | The generation log. |
| Code | The code once it has been written. |
While the AI works, an Agent Thinking box explains what it is doing next.
Stopping a generation
Use Stop on a card's menu, in the drawer, in the selection bar for selected cards, or in the page header to stop everything that is generating. The confirmation reminds you that the Flairs already used are not refunded. A stopped script shows Generation cancelled and can be regenerated.
The Test Scripts tab

Every test case that has a script appears as a card showing its code, name, status, URL, language, framework and the number of linked bugs.
| Control | What it does |
|---|---|
| All / Completed / Failed | Quick status toggle |
| Search and filters | Search by name; filter by Status (Generating/Running, Completed, Failed) and Automation framework |
| Show code | Expands the card to show the code, or switch to Logs |
| Run icon | Runs the script, or reruns it. See Test Execution |
| Regenerate | Shown instead of Run when generation failed or was cancelled |
| ⋯ menu | Stop, Generation details, Execution history, Export, Copy script ID, Delete |
Select cards to act on several at once: Run, Rerun, Regenerate, Stop, Export and Delete appear in the selection bar when they apply. The page's ⋯ menu exports or deletes all scripts. Deleting a script keeps the test case and sets it back to Pending.
Copy script ID copies the ID you need to run the script from a CI pipeline. See Git Integrations.
Status tags
| Tag | Meaning |
|---|---|
| Generating... | The AI is exploring or writing code |
| Generation completed | The script is ready to run |
| Generation failed | Generation didn't finish. Regenerate it |
| Generation cancelled | Someone stopped it |
Once a script has been run, the card shows the latest execution result instead (for example Execution Success or Execution Failed). See Test Execution.
Reading and editing the code
Click a finished card to open its drawer, or maximize the drawer to a full page.
| Tab | Shows |
|---|---|
| Code | The script, editable in a code editor |
| Logs | The generation log |
| Execution history | Every run of this script |
| Properties | The script's details, such as its test case and when it was created (drawer only) |
Scripts follow the Page Object Model. The Classes list on the left of the code shows:
- a base class with the browser setup shared by the test,
- the test class with the test itself,
- one page class per page of your application, holding that page's elements and actions.
Pick a class to view or edit it, then click Save. If you close with unsaved changes, TestFlair asks before discarding them. The drawer footer also has Run (or Rerun), and Regenerate for a failed script.
Regenerating replaces your edits with a fresh script. If you have changed the code by hand, export it first.
Exporting
Export downloads a .zip containing a ready-to-run Maven project: the Java sources, a pom.xml, a testng.xml and a README. A script with preconditions is exported together with them so it runs on its own. Export works for completed scripts, one at a time or several at once.
Troubleshooting
"To generate test scripts you need to add URL to at least 1 test case"
- Add a URL to the test cases you want scripts for, on the Test Cases tab.
Generation failed
- Open Generation details and read the Action Log and Generation Logs to see where it stopped. Common causes: the URL isn't reachable from the internet (see Testing local applications), the login data in your test data is wrong, or a step describes something the page doesn't have. Fix the test case or its test data, then Regenerate.
The framework option is disabled
- A precondition of the test case uses the other framework. Generate with that framework, or regenerate the precondition first.
The Generate button is greyed out
- Your Flair balance is below the estimated cost. See Billing.
Next Steps
- Test Execution — Run a script and read its results
- Test Runs — Run many scripts together as a set
- Test Cases — Refine steps, test data and preconditions
- Watching the AI Explore — The live browser during generation