- Call
screenshot()to save one at a specific point. - Turn on
autoScreenshotsto save one before and after each command, named after the line that ran it.
.testdriver/screenshots/<test file>/.
Save a screenshot by hand
Callscreenshot() with an optional file name. It resolves to the absolute path of the saved file:
tests/login.test.mjs
- TestDriver adds
.pngif the name doesn’t end with it. - Without a name, the file is called
screenshot-<timestamp>.png.
Save screenshots automatically
SetautoScreenshots: true when you create the client:
error screenshot instead of the after one. A failed screenshot never fails the command.
Automatic screenshots are off by default because each one is an extra capture from the sandbox.
Which commands are captured
find()andfindAll().- Methods you call on the client, such as
testdriver.click(),type(),pressKeys(),scroll(),hover(),wait(),assert(),extract(),exec(), andfocusApplication().
Methods you call on an element, such as
element.click() or element.hover(), aren’t captured. The find() that returned the element is.File names
Each automatic screenshot is named:
The description comes from:
- The description passed to
find()orfindAll(). - The first 20 characters typed by
type(). - The keys passed to
pressKeys(), joined with+. - The direction passed to
scroll(). - The first 30 characters of the text passed to
assert()orextract().
Example
This test:Where screenshots are saved
Screenshots go in a folder named after the test file, without its last extension:
The
.testdriver folder is created in the directory you run the tests from.
TestDriver deletes a test file’s screenshot folder when that file’s first test connects to a sandbox. Each folder only holds screenshots from the latest run. Tests in the same file running at the same time don’t delete each other’s screenshots.
Review the screenshots
Open the folder after a run, or ask your AI assistant to find and show screenshots by line number. Debug a failing test explains how to do that with the TestDriver MCP server.Related
- screenshot(): the reference for manual screenshots
- Debug a failing test: use replays and screenshots to find out why a test failed
- Dashcam: the video recording of each run
- Options: every client option

