mcpbeat Sign in

Testdriver:screenshot Agent Skill

Capture and save screenshots during test execution

2k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
237
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/testdriverai/testdriverai --skill testdriver:screenshot

The instruction itself

18 sections, as written by the author

<!-- Generated from screenshot.mdx. DO NOT EDIT. -->

Overview

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>

Syntax

const filePath = await testdriver.screenshot(filename)

Parameters

<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>

Returns

Promise<string> - The absolute file path where the screenshot was saved

File Organization

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
      ...

Automatic Screenshot Naming

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>

Examples

Basic Screenshot

// Capture a screenshot with auto-generated filename
const screenshotPath = await testdriver.screenshot();
console.log('Screenshot saved to:', screenshotPath);

Custom Filename

// 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

Debugging with Screenshots

import { 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("[email protected]");

    // 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();
  });
});

Automatic Screenshots

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.

Enabling/Disabling

// Auto-screenshots enabled by default
const testdriver = TestDriver(context);

// Explicitly disable if needed (not recommended)
const testdriver = TestDriver(context, {
  autoScreenshots: false
});

What Gets Captured

Automatic screenshots are taken around these commands:

  • find() / findAll()
  • click() / hover() / doubleClick() / rightClick()
  • type() / pressKeys()
  • scroll()
  • waitForText() / waitForImage()
  • focusApplication()
  • assert() / extract() / exec()

Example Output

For this test code:

// 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("[email protected]");

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.png

If an error occurs, the phase will be error instead of after.

Best Practices

<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.

    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>

Viewing Saved Screenshots

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.

MCP Commands for Screenshot Viewing

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:

  • View screenshots from failed tests to understand what went wrong
  • Review test execution flow by examining screenshots in chronological order
  • Compare screenshots across test runs to identify flaky behavior

<Note>

For detailed workflows and examples of using these MCP commands for debugging, see the Debugging with Screenshots guide.

</Note>

  • Debugging with Screenshots - View and analyze saved screenshots using MCP
  • assert() - Make AI-powered assertions
  • find() - Locate elements on screen

Other skills for the same job

different authors, same section of the catalogue
Screenshot
by openai
vendor ×1

Use when the user explicitly asks for a desktop or system screenshot (full screen, specific app or window, or a pixel region), or when tool-specific capture capabilities are unavailable and an OS-level capture is needed.

13k tokens scripts
Ios Simulator Browser
by openai
vendor

Mirror an iOS Simulator into the Codex in-app browser and render SwiftUI previews from importable Swift packages in that simulator with hot reload. Use when a user wants to watch or interact with an iOS app in the browser, see a SwiftUI preview outside Xcode Canvas, iterate live on a preview, or capture browser-visible simulator proof.

18k tokens scripts
Doc Screenshots
by WordPress

Annotate UI screenshots with documentation callouts in Fellyph's established visual style — uniform-width orange arrows with white halos, double-stroke target outlines, numbered callout cards, dim overlays and a framed canvas. Use this whenever the user asks to annotate a screenshot, add arrows or callouts to a screenshot, create documentation images, highlight UI controls in a capture, or produce docs/tutorial visuals for Playground, Studio or any web UI — even if they just say "add arrows to this" or "make a docs screenshot".

9k tokens scripts
Create Imessage Mockup
by gooseworks-ai

Render pixel-accurate iMessage screenshot mockups (DM or group) from a thread JSON. Supports minimal, with-keyboard, and full iPhone 15 Pro frame variants. Outputs HTML + PNG.

19k tokens scripts
Goose Graphics Create Style
by gooseworks-ai

> End-to-end skill that turns a single reference image into a published Gooseworks style — analyzes the image, drafts the slim style spec, renders a hero example plus 2-3 additional formats via Playwright, writes the `gooseworks-style.json` manifest, and publishes via `npx gooseworks styles publish` so other agents can discover it. Mirrors goose-graphics-create-format but for styles.

5k tokens
Asc Screenshot Resize
by rorkai

Resize and validate App Store screenshots with current asc screenshot-size data and macOS sips. Use when preparing or fixing screenshots for App Store Connect submission.

927 tokens
Screenshot Automation
by rshankras

Generates an automated App Store screenshot pipeline with UI tests for screenshot capture, device framing, localized caption overlays, and multi-size batch export. Use when user wants automated screenshots, App Store screenshot generation, or a fastlane snapshot replacement.

23k tokens
Agent Canvas Setup
by majiayu000

Dependency checker and installer for agent-canvas, agent-eyes, and canvas-edit skills. Use BEFORE running any canvas skill for the first time, or when canvas skills fail with import/browser errors. Triggers on "setup agent canvas", "install canvas dependencies", "canvas not working", "playwright not found", or any setup/installation request for canvas skills.

1k tokens

How to use it

Copy the folder

Take testdriverai/testdriver:screenshot from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.