browser_screenshot
Capture webpage screenshots in Windows automation workflows. Save screenshots to specified paths and choose between visible area or full-page captures for documentation and testing purposes.
Instructions
截取网页截图
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | 保存路径(可选) | |
| fullPage | No | 是否整页截图(可选) | |
| sessionId | No | 会话 ID(可选) |
Input Schema (JSON Schema)
{
"properties": {
"fullPage": {
"description": "是否整页截图(可选)",
"type": "boolean"
},
"path": {
"description": "保存路径(可选)",
"type": "string"
},
"sessionId": {
"description": "会话 ID(可选)",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/browser.js:217-234 (handler)Core implementation of the browser_screenshot tool. Takes screenshot of the page associated with sessionId, saves to specified path or generates default timestamped path, supports fullPage option.async screenshot(savePath, fullPage = false, sessionId = 'default') { try { const page = this.pages.get(sessionId); if (!page) { return { success: false, error: '浏览器未启动' }; } const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const defaultPath = `screenshot-browser-${timestamp}.png`; const path = savePath || defaultPath; await page.screenshot({ path, fullPage }); return { success: true, path, fullPage, message: '截图已保存' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/browser.js:78-85 (schema)Input schema defining optional parameters: path (save location), fullPage (boolean for full page screenshot), sessionId (browser session identifier).inputSchema: { type: 'object', properties: { path: { type: 'string', description: '保存路径(可选)' }, fullPage: { type: 'boolean', description: '是否整页截图(可选)' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, },
- src/tools/browser.js:75-86 (registration)Tool definition object in getToolDefinitions() method, registering the browser_screenshot tool with name, description, and schema.{ name: 'browser_screenshot', description: '截取网页截图', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '保存路径(可选)' }, fullPage: { type: 'boolean', description: '是否整页截图(可选)' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, }, },
- src/tools/browser.js:135-136 (registration)Dispatch logic in executeTool() switch statement, routing browser_screenshot calls to the screenshot handler.case 'browser_screenshot': return await this.screenshot(args.path, args.fullPage, args.sessionId);
- src/tools/browser.js:113-115 (registration)Inclusion of 'browser_screenshot' in the canHandle() tool list for tool dispatching.const tools = ['browser_launch', 'browser_navigate', 'browser_click', 'browser_type', 'browser_screenshot', 'browser_get_text', 'browser_close']; return tools.includes(toolName);