screenshot
Capture browser screenshots during automated web testing to document page states and verify visual elements.
Instructions
Take a screenshot of the current page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the screenshot file (without extension) |
Implementation Reference
- src/browser.ts:83-89 (handler)The handler function that performs the screenshot operation using Puppeteer on the current page, sanitizes the filename, saves the PNG to the current working directory, and returns the saved path.async screenshot(name: string) { const page = await this.init(); const filename = `${name.replace(/[^a-z0-9]/gi, '_').toLowerCase()}.png`; const filepath = path.resolve(process.cwd(), filename); await page.screenshot({ path: filepath }); return `Screenshot saved to ${filepath}`; }
- src/index.ts:74-80 (schema)Defines the JSON schema for the screenshot tool input, requiring a 'name' string parameter.inputSchema: { type: "object", properties: { name: { type: "string", description: "Name for the screenshot file (without extension)" }, }, required: ["name"], },
- src/index.ts:71-81 (registration)Registers the screenshot tool in the TOOLS array used by the ListToolsRequestSchema handler.{ name: "screenshot", description: "Take a screenshot of the current page", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name for the screenshot file (without extension)" }, }, required: ["name"], }, },
- src/index.ts:132-134 (registration)Dispatches the screenshot tool call in the CallToolRequestSchema switch statement by invoking browserManager.screenshot.case "screenshot": result = await browserManager.screenshot(String(args?.name)); break;