Overview
TestDriver MCP provides powerful commands to view and analyze screenshots saved during test execution. This enables rapid debugging, test development, and comparison workflows without manually opening image files.Automatic Screenshots (Default: Enabled): TestDriver automatically captures screenshots before and after every command. Screenshots are named with the line number and action, making it easy to trace exactly which line of code produced each screenshot. For example:
001-click-before-L42-submit-button.pngMCP Commands
list_local_screenshots
List and filter screenshots saved in the.testdriver/screenshots/ directory:
Filter screenshots by test file or subdirectory (e.g., “login.test”, “mcp-screenshots”). If omitted, lists all screenshots.
Filter by exact line number from test file (e.g., 42 matches L42 in filename).
Filter by line number range. Example:
{ start: 10, end: 20 } matches screenshots from lines 10-20.Filter by action type:
click, find, type, assert, provision, scroll, hover, etc.Filter by phase:
"before" (state before action) or "after" (state after action).Regex pattern to match against filename. Example:
"login|signin" or "button.*click".Filter by exact sequence number.
Filter by sequence range. Example:
{ start: 1, end: 10 } matches first 10 screenshots.Maximum number of results to return (default: 50).
Sort results by:
"modified" (newest first, default), "sequence" (execution order), or "line" (line number).path- Full absolute path to the screenshot filerelativePath- Path relative to.testdriver/screenshots/name- Screenshot filenamesizeBytes- File size in bytesmodified- Last modification timestampsequence- Sequential number (from auto-screenshots)action- Action type (click, find, etc.)phase- Before/after phaselineNumber- Line number from test filedescription- Element or action description
view_local_screenshot
View a specific screenshot from the list:Full absolute path to the screenshot file (as returned by
list_local_screenshots)- Image content (displayed to both AI and user via MCP App)
- Screenshot metadata
- Success/error status
Common Workflows
Test Debugging After Failures
When a test fails, use powerful filtering to quickly find relevant screenshots: 1. Find screenshots at the failing line:Finding Specific Actions
When debugging element interactions:Understanding Test Flow
View screenshots in execution order to trace test behavior:Interactive Test Development
While building tests using MCP tools, view screenshots to verify your test logic:- After a test run, filter screenshots to see specific actions:
- Review key points in the test execution:
- Verify element locations and states before adding assertions
- Iterate - adjust your test code based on what you see in the screenshots
Comparison and Analysis
Compare screenshots to identify issues: Using phase filtering for before/after comparison:Best Practices
Use descriptive filenames
Use descriptive filenames
When saving screenshots in tests, use descriptive names to make them easier to identify:Then when listing screenshots, you can quickly identify key moments without viewing every image.
List before viewing
List before viewing
Always call
list_local_screenshots first to see what’s available. The list is sorted by modification time (newest first), making it easy to find recent test runs.Filter by test file
Filter by test file
When debugging a specific test, use the This avoids clutter from other tests.
directory parameter to filter screenshots:View screenshots before and after failures
View screenshots before and after failures
When a test fails (especially with assertions), look at screenshots immediately before the failure. They show exactly what the AI or test “saw” at that moment, helping you understand why an assertion failed or why an element wasn’t found.
Combine with test reports
Combine with test reports
TestDriver test reports include screenshots in the timeline. Use MCP screenshot viewing for interactive debugging during development, and test reports for post-run analysis and team sharing.
Archive important screenshots
Archive important screenshots
Remember that each test run clears its screenshot folder. If you need to preserve screenshots for comparison:
Screenshot File Organization
Understanding the directory structure helps with efficient screenshot viewing:Automatic Screenshot Naming Format
<seq>-<action>-<phase>-L<line>-<description>.png
| Component | Description | Example |
|---|---|---|
seq | Sequential number | 001, 002 |
action | Command name | click, type, find |
phase | Before, after, or error | before, after, error |
L<line> | Line number from test file | L42 |
description | Element/action description | submit-button |
Key Points
- Each test file gets its own subdirectory
- Automatic screenshots include line numbers for easy tracing
- Manual
screenshot()calls use custom names you provide - Folders are cleared at the start of each test run
- All screenshots are PNG format
- Disable automatic screenshots with
autoScreenshots: falseif needed
Integration with Test Development
During MCP Interactive Development
When using TestDriver MCP tools (session_start, find_and_click, etc.), screenshots are automatically captured and displayed. Additionally, you can view previously saved screenshots:
After Test Runs
When tests fail or behave unexpectedly:- Run the test with
vitest run tests/my-test.test.mjs - List screenshots using
list_local_screenshots - View relevant screenshots to diagnose the issue
- Update test code based on what you see
- Re-run and verify the fix
Troubleshooting
No screenshots found
No screenshots found
If
list_local_screenshots returns an empty array:- Ensure your test includes
await testdriver.screenshot()calls - Verify the test actually ran (check test output)
- Check that
.testdriver/screenshots/directory exists - Confirm you’re in the correct project directory
Screenshot not displaying
Screenshot not displaying
If
view_local_screenshot returns an error:- Verify the path is exactly as returned by
list_local_screenshots - Check file permissions - ensure the screenshot file is readable
- Confirm the file hasn’t been deleted or moved
Too many screenshots
Too many screenshots
If you have hundreds of screenshots making it hard to find what you need, use filtering:
- Filter by test file:
list_local_screenshots({ directory: "my-test.test" }) - Filter by line number:
list_local_screenshots({ line: 42 })orlist_local_screenshots({ lineRange: { start: 40, end: 50 } }) - Filter by action:
list_local_screenshots({ action: "click" }) - Filter by phase:
list_local_screenshots({ phase: "before" }) - Use regex:
list_local_screenshots({ pattern: "submit|login" }) - Limit results:
list_local_screenshots({ limit: 10 }) - Sort by line:
list_local_screenshots({ sortBy: "line" }) - Clean up old folders:
rm -rf .testdriver/screenshots/*
Screenshots from old test runs
Screenshots from old test runs
Remember that screenshot folders are cleared at the start of each test run. If you see old screenshots:
- The test may not have run recently
- Or the test failed before reaching the clearing logic
- Manually clear:
rm -rf .testdriver/screenshots/<test-name>/
Related
- screenshot() - Capture screenshots during test execution
- Dashcam - Record full test sessions with video and logs
- assert() - Make AI-powered assertions that benefit from screenshot context

