type
Enter text into a web page field by ID or CSS selector, with an optional Enter key press for form submission.
Instructions
Type into a field by id (from inspect) or CSS selector. Set submit=true to press Enter after.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| id | No | ||
| selector | No | ||
| submit | No |
Implementation Reference
- src/index.ts:287-304 (handler)The main handler function for the 'type' tool. It types text into a field identified by id (from inspect) or CSS selector. Optionally presses Enter after if submit=true.
async function type(args: { text: string; id?: number; selector?: string; submit?: boolean }) { const p = requirePage(); let loc; if (args.id !== undefined) { const tagged = await p.evaluate(() => document.querySelector('[data-helm-id]') !== null); if (!tagged) await tagInteractive(p); loc = p.locator(`[data-helm-id="${args.id}"]`).first(); if ((await loc.count()) === 0) { throw new Error(`No element with helm id=${args.id}. Run inspect() first.`); } } else if (args.selector) { loc = p.locator(args.selector).first(); } else { throw new Error('Provide {id} or {selector}.'); } await loc.fill(args.text); if (args.submit) await loc.press('Enter'); return { ok: true }; - src/index.ts:400-412 (schema)The input schema definition for the 'type' tool. Defines properties: text (required), id (optional number), selector (optional string), submit (optional boolean).
{ name: 'type', description: 'Type into a field by id (from inspect) or CSS selector. Set submit=true to press Enter after.', inputSchema: { type: 'object', properties: { text: { type: 'string' }, id: { type: 'number' }, selector: { type: 'string' }, submit: { type: 'boolean' }, }, required: ['text'], }, - src/index.ts:467-467 (registration)Registration of the 'type' tool in the CallToolRequestSchema switch statement, mapping 'type' tool name to the type() handler function.
case 'type': result = await type(args as { text: string; id?: number; selector?: string; submit?: boolean }); break; - src/index.ts:46-46 (helper)The INTERACTIVE_SELECTOR includes 'input:not([type="hidden"])' which is part of the element discovery mechanism used by inspect() that feeds ids to type().
'input:not([type="hidden"])',