Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Capture and save screenshots during test execution
.claude/skills/testdriverai-testdriver-screenshot/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 95% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 19% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 52% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -4% | 0% |
<!-- Generated from screenshot.mdx. DO NOT EDIT. -->
Capture a screenshot of the current screen and automatically save it to a local file. Screenshots are organized by test file for easy debugging and review.
<Note> Automatic Screenshots: TestDriver can automatically capture screenshots before and after every command (click, type, find, etc.). These are saved with descriptive filenames like 001-click-before-L42-submit-button.png that include the line number from your test file. Enable this with autoScreenshots: true in your TestDriver options. </Note>
javascriptconst filePath = await testdriver.screenshot(filename)
<ParamField path="filename" type="string" optional> Custom filename for the screenshot (without .png extension). If not provided, a timestamp-based filename is generated automatically. </ParamField>
Promise<string> - The absolute file path where the screenshot was saved
Screenshots are automatically saved to .testdriver/screenshots/<test-file-name>/ in your project root:
.testdriver/
screenshots/
login.test/
001-find-before-L15-email-input.png # Auto: before find()
002-find-after-L15-email-input.png # Auto: after find()
003-click-before-L16-email-input.png # Auto: before click()
004-click-after-L16-email-input.png # Auto: after click()
005-type-before-L17-userexamplecom.png # Auto: before type()
006-type-after-L17-userexamplecom.png # Auto: after type()
custom-screenshot.png # Manual: screenshot("custom-screenshot")
checkout.test/
001-find-before-L12-checkout-button.png
...When autoScreenshots is enabled, filenames follow this format:
<seq>-<action>-<phase>-L<line>-<description>.png
| Component | Description | Example | |-----------|-------------|---------| | seq | Sequential number (001, 002, ...) | 001 | | action | Command name | click, type, find | | phase | Before, after, or error | before, after | | L<line> | Line number from test file | L42 | | description | Element description or action target | submit-button |
<Note> The screenshot folder for each test file is automatically cleared when the test starts. This ensures you only see screenshots from the most recent test run. </Note>
javascript// Capture a screenshot with auto-generated filename const screenshotPath = await testdriver.screenshot(); console.log('Screenshot saved to:', screenshotPath);
javascript// Save with a descriptive filename await testdriver.screenshot("login-page"); // Saves to: .testdriver/screenshots/<test>/login-page.png await testdriver.screenshot("after-click"); // Saves to: .testdriver/screenshots/<test>/after-click.png
javascriptimport { describe, expect, it } from "vitest"; import { TestDriver } from "testdriverai/vitest/hooks"; describe("Login Flow", () => { it("should log in successfully", async (context) => { const testdriver = TestDriver(context); await testdriver.provision.chrome({ url: 'https://myapp.com/login', }); // Capture initial state await testdriver.screenshot(); // Fill in login form const emailInput = await testdriver.find("email input"); await emailInput.click(); await testdriver.type("user@example.com"); // Capture state after typing await testdriver.screenshot(); const passwordInput = await testdriver.find("password input"); await passwordInput.click(); await testdriver.type("password123"); // Capture before clicking login await testdriver.screenshot(); const loginButton = await testdriver.find("Login button"); await loginButton.click(); // Capture after login attempt await testdriver.screenshot(); const result = await testdriver.assert("dashboard is visible"); expect(result).toBeTruthy(); }); });
By default, TestDriver captures screenshots automatically before and after every command. This creates a complete visual timeline of your test execution without any additional code.
javascript// Auto-screenshots enabled by default const testdriver = TestDriver(context); // Explicitly disable if needed (not recommended) const testdriver = TestDriver(context, { autoScreenshots: false });
Automatic screenshots are taken around these commands:
find() / findAll()click() / hover() / doubleClick() / rightClick()type() / pressKeys()scroll()waitForText() / waitForImage()focusApplication()assert() / extract() / exec()For this test code:
javascript// Line 15: Find email input const emailInput = await testdriver.find("email input"); // Line 16: Click it await emailInput.click(); // Line 17: Type email await testdriver.type("user@example.com");
TestDriver automatically saves:
001-find-before-L15-email-input.png
002-find-after-L15-email-input.png
003-click-before-L16-email-input.png
004-click-after-L16-email-input.png
005-type-before-L17-userexamplecom.png
006-type-after-L17-userexamplecom.pngIf an error occurs, the phase will be error instead of after.
<AccordionGroup> <Accordion title="Let automatic screenshots do the work"> With autoScreenshots: true, you get comprehensive coverage without adding manual screenshot() calls. Only add manual screenshots for specific named checkpoints. </Accordion>
<Accordion title="Use screenshots for debugging flaky tests"> When a test fails intermittently, add screenshots at key steps to capture the actual screen state. This helps identify timing issues or unexpected UI states. </Accordion>
<Accordion title="Capture before assertions"> Take a screenshot before making assertions. If the assertion fails, you'll have a visual record of what the screen looked like.
javascript await testdriver.screenshot(); const result = await testdriver.assert("checkout button is visible"); </Accordion>
<Accordion title="Add to .gitignore"> Add .testdriver/screenshots/ to your .gitignore to avoid committing screenshots to version control:
# .gitignore .testdriver/screenshots/ </Accordion> </AccordionGroup>
After saving screenshots during test execution, you can view them using TestDriver MCP commands. This is especially useful for debugging failed tests or verifying test behavior.
List all saved screenshots:
list_local_screenshots()View a specific screenshot:
view_local_screenshot({ path: "/full/path/to/screenshot.png" })These commands allow you to:
<Note> For detailed workflows and examples of using these MCP commands for debugging, see the Debugging with Screenshots guide. </Note>
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 10,507 | 7,447 | -29% | 1 | 1 | 0% | 2,033 | 3,253 | +60% | 0 | 0 | — |
case-02 | fail→pass | 10,066 | 6,740 | -33% | 1 | 1 | 0% | 1,728 | 3,365 | +95% | 0 | 0 | — |
case-03 | fail→pass | 13,180 | 2,766 | -79% | 1 | 1 | 0% | 2,055 | 2,453 | +19% | 0 | 0 | — |
case-04 | pass→pass | 8,033 | 4,580 | -43% | 1 | 1 | 0% | 1,311 | 2,863 | +118% | 0 | 0 | — |
case-05 | fail→pass | 9,217 | 2,674 | -71% | 1 | 1 | 0% | 1,573 | 2,494 | +59% | 0 | 0 | — |
case-06 | fail→pass | 9,636 | 2,934 | -70% | 1 | 1 | 0% | 1,644 | 2,506 | +52% | 0 | 0 | — |
case-07 | fail→pass | 15,537 | 2,555 | -84% | 1 | 1 | 0% | 2,439 | 2,350 | -4% | 0 | 0 | — |
case-08 | pass→pass | 7,325 | 1,842 | -75% | 1 | 1 | 0% | 1,190 | 2,257 | +90% | 0 | 0 | — |
case-09 | pass→pass | 6,890 | 2,349 | -66% | 1 | 1 | 0% | 1,105 | 2,309 | +109% | 0 | 0 | — |
case-10 | fail→pass | 7,667 | 1,671 | -78% | 1 | 1 | 0% | 1,292 | 2,237 | +73% | 0 | 0 | — |
case-11 | fail→pass | 6,277 | 1,543 | -75% | 1 | 1 | 0% | 1,078 | 2,198 | +104% | 0 | 0 | — |
case-12 | pass→pass | 10,713 | 3,090 | -71% | 1 | 1 | 0% | 1,700 | 2,467 | +45% | 0 | 0 | — |
case-13 | fail→pass | 9,793 | 2,075 | -79% | 1 | 1 | 0% | 1,726 | 2,220 | +29% | 0 | 0 | — |
case-14 | fail→pass | 7,764 | 2,316 | -70% | 1 | 1 | 0% | 1,104 | 2,337 | +112% | 0 | 0 | — |
case-15 | pass→pass | 3,860 | 2,360 | -39% | 1 | 1 | 0% | 704 | 2,371 | +237% | 0 | 0 | — |
case-16 | pass→pass | 7,992 | 3,524 | -56% | 1 | 1 | 0% | 1,198 | 2,482 | +107% | 0 | 0 | — |
case-17 | pass→pass | 8,048 | 2,243 | -72% | 1 | 1 | 0% | 1,328 | 2,328 | +75% | 0 | 0 | — |
case-18 | fail→pass | 6,320 | 2,486 | -61% | 1 | 1 | 0% | 1,068 | 2,394 | +124% | 0 | 0 | — |
case-19 | fail→pass | 7,854 | 2,400 | -69% | 1 | 1 | 0% | 1,344 | 2,382 | +77% | 0 | 0 | — |
case-20 | fail→pass | 9,379 | 3,176 | -66% | 1 | 1 | 0% | 1,714 | 2,551 | +49% | 0 | 0 | — |
case-21 | pass→pass | 12,695 | 6,345 | -50% | 1 | 1 | 0% | 1,944 | 2,893 | +49% | 0 | 0 | — |
case-22 | pass→pass | 14,146 | 1,642 | -88% | 1 | 1 | 0% | 1,769 | 2,183 | +23% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +55 percentage points is the difference between those two pass rates over the 22 comparable cases.
The publisher has shipped newer versions since this run, so these numbers describe v1, not the version currently listed.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.