- The agent runs in your AI coding assistant.
- It runs the flow in a live sandbox and writes a Vitest test.
- It finds elements by looking at the screen, so you never write selectors.
Before you begin
Install TestDriver in an AI coding assistant that can edit files in your repository:- Claude Code: install the plugin.
- VS Code or Cursor: install the extension.
- Any other assistant: run
npx testdriverai initin your repository and choose your assistant. See Set up a project.
Start the agent
Ask for the TestDriver agent by name in your assistantโs chat:Describe the test
Write the flow as the steps a user takes and what they should see at the end. Explicit steps make a test faster, cheaper, and more reliable than one where the agent works out the flow itself:Watch and steer the run
The agent sends a screenshot after every action, so you see what it sees.- In clients that support MCP Apps, each screenshot appears inline in the chat, with the targeted element highlighted.
- With the TestDriver extension in VS Code or Cursor, the sandbox also plays live in a panel beside your code.
What the agent does
- Starts a session. It provisions a sandbox (Linux by default) and opens your app, for example Chrome at the URL you gave it.
- Performs each step. It finds each element from a description, acts on it, and checks the screenshot to confirm the step worked.
- Writes code as it goes. After each successful action, it appends the matching SDK code to a test file under
tests/. The file always reflects what has actually run. - Runs the test. It runs the file with
vitest runand keeps fixing it until it passes.
Review the generated test
The result is an ordinary Vitest file. Read, edit, commit, and run it in CI like any other test:tests/login.test.mjs
- Each
find()description would still pick the right element if the page changed. - The assertions cover what you care about.
Tips for better tests
Describe elements by what they look like
Describe elements by what they look like
โThe blue Sign In button in the headerโ works better than โthe buttonโ. Include the visible label. Add position or color when several elements look alike. See Locate elements.
Mention loading and animations
Mention loading and animations
If part of your app loads slowly, say so. For example: โwait for the loading spinner to disappear before continuingโ. The agent then waits instead of acting too early.
Assert after each important step
Assert after each important step
Assert after each meaningful action, such as โthe item appears in the cartโ. When the test fails later, you see where the regression starts.
Build long flows in pieces
Build long flows in pieces
Donโt describe a long workflow all at once. Have the agent get the first part passing, then describe the next.
Next steps
Run tests
Choose a device, preview mode, and how to run your tests.
Speed up reruns with caching
Reuse what TestDriver found so reruns skip the AI.
Make assertions
Write checks that catch the regressions you care about.
Run in CI/CD
Run generated tests on every pull request.

