Documentation Index
Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TestDriver can capture screenshots manually at any point during a test, or automatically before and after every command. Screenshots are saved to a structured directory for easy debugging.Manual Screenshots
Usetestdriver.screenshot() to capture the current screen:
Options
Custom filename for the screenshot.
.png is appended automatically if missing. If omitted, defaults to screenshot-<timestamp>.png.Promise<string> — the absolute file path of the saved screenshot.
Auto Screenshots
Enable automatic screenshots before and after every command:When
true, captures a screenshot before and after every SDK command (click, type, find, scroll, hover, pressKeys, assert, exec, etc.). On error, an error-phase screenshot replaces the after-phase screenshot.Filename Format
Auto-screenshots follow this naming convention:| Part | Description | Example |
|---|---|---|
seq | 3-digit zero-padded sequence number | 001 |
action | Command name | click, type, find |
phase | before, after, or error | before |
L<line> | Source line number from your test file | L42 |
description | Sanitized from command arguments (max 30 chars) | submit-button |
Phases
| Phase | When | Description |
|---|---|---|
before | Before command executes | Captures the screen state before the action |
after | After successful command | Captures the result of the action |
error | After failed command | Captures the screen at the point of failure (replaces after) |
Screenshot Directory
Screenshots are saved to:<testFileName> is the test file name without its extension. For example, a test at tests/login.test.mjs saves screenshots to .testdriver/screenshots/login.test/.
Directory Cleanup
The screenshot directory for each test file is automatically cleaned at the start of a test run. This happens once per process per test file to prevent concurrent tests from the same file from interfering with each other.Debug Screenshots
Elements have asaveDebugScreenshot() method for debugging element detection:
find() call, which can be useful for understanding what the AI “saw” when locating the element.

