capture_screenshot
Capture and save Android device screenshots to a specific test folder for streamlined debugging and testing, using step-based naming for organized storage.
Instructions
Capture a screenshot and save it to the test folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| step_name | Yes | Name of the step for the screenshot file (e.g., "001_login") | |
| test_name | Yes | Name of the test folder where to save the screenshot |
Implementation Reference
- src/tools/handlers.ts:97-129 (handler)The main handler function for the capture_screenshot tool. It extracts test_name and step_name from args, constructs paths, ensures directory exists, executes adb screencap to save PNG, reads and base64 encodes it, returns text confirmation and image artifact.capture_screenshot: async (args: any) => { const { test_name, step_name } = args as { test_name: string; step_name: string; }; const testPath = path.join(getBaseTestPath(), test_name); const screenshotPath = path.join(testPath, `${step_name}_step.png`); if (!fs.existsSync(testPath)) { fs.mkdirSync(testPath, { recursive: true }); } await executeCommand(`adb exec-out screencap -p > "${screenshotPath}"`); // Read the screenshot file and convert to base64 const imageData = fs.readFileSync(screenshotPath); const base64Image = imageData.toString('base64'); return { content: [ { type: 'text', text: `Screenshot captured: ${screenshotPath}`, }, { type: 'image', data: base64Image, mimeType: 'image/png', }, ], }; },
- src/tools/definitions.ts:44-61 (schema)The input schema and metadata definition for the capture_screenshot tool, used for tool listing and validation. Specifies required parameters test_name and step_name.{ name: 'capture_screenshot', description: 'Capture a screenshot and save it to the test folder', inputSchema: { type: 'object', properties: { test_name: { type: 'string', description: 'Name of the test folder where to save the screenshot', }, step_name: { type: 'string', description: 'Name of the step for the screenshot file (e.g., "001_login")', }, }, required: ['test_name', 'step_name'], }, },