Overview
TestDriver can capture screenshots by hand at any point during a test. It can also capture them automatically before and after each command. TestDriver saves the screenshots to a structured directory. This makes debug easy.Manual Screenshots
Usetestdriver.screenshot() to capture the present screen:
Options
string
A custom filename for the screenshot. TestDriver adds
.png automatically if it is not there. If you do not give this, the default is screenshot-<timestamp>.png.Promise<string> — the absolute file path of the saved screenshot.
Auto Screenshots
Enable automatic screenshots before and after every command:boolean
default:false
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:
Examples:
Phases
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.

