browser_type
Input text into browser elements using CSS selectors for automated web interactions within Windows automation workflows.
Instructions
输入文本到元素
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS 选择器 | |
| text | Yes | 要输入的文本 | |
| sessionId | No | 会话 ID(可选) |
Implementation Reference
- src/tools/browser.js:201-215 (handler)The `type` method implements the core logic for the 'browser_type' tool: waits for the selector, types the provided text into the element using Puppeteer.async type(selector, text, sessionId = 'default') { try { const page = this.pages.get(sessionId); if (!page) { return { success: false, error: '浏览器未启动' }; } await page.waitForSelector(selector, { timeout: 5000 }); await page.type(selector, text); return { success: true, selector, text, message: '输入成功' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/browser.js:63-74 (schema)Input schema definition for the 'browser_type' tool, specifying parameters: selector (required), text (required), and optional sessionId.name: 'browser_type', description: '输入文本到元素', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS 选择器' }, text: { type: 'string', description: '要输入的文本' }, sessionId: { type: 'string', description: '会话 ID(可选)' }, }, required: ['selector', 'text'], }, },
- src/tools/browser.js:133-134 (registration)Dispatch in `executeTool` method that routes 'browser_type' calls to the `type` handler.case 'browser_type': return await this.type(args.selector, args.text, args.sessionId);
- src/tools/browser.js:113-115 (registration)Inclusion of 'browser_type' in the `canHandle` method's tool list for capability checking.const tools = ['browser_launch', 'browser_navigate', 'browser_click', 'browser_type', 'browser_screenshot', 'browser_get_text', 'browser_close']; return tools.includes(toolName);