Skip to main content
Glama

browser_type

Type text into web page elements during browser automation, with options to submit text or simulate character-by-character typing for testing interactive features.

Instructions

Type text into editable element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot
textYesText to type into the element
submitNoWhether to submit entered text (press Enter after)
slowlyNoWhether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.

Implementation Reference

  • The main handler function implementing the logic for the 'browser_type' tool. It resolves the locator from the page snapshot, generates code snippets for execution, prepares action steps for typing or filling text (slowly or fast), optionally submits with Enter, and returns code and action for execution.
    handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code: string[] = []; const steps: (() => Promise<void>)[] = []; if (params.slowly) { code.push(`// Press "${params.text}" sequentially into "${params.element}"`); code.push(`await page.${await generateLocator(locator)}.pressSequentially(${javascript.quote(params.text)});`); steps.push(() => locator.pressSequentially(params.text)); } else { code.push(`// Fill "${params.text}" into "${params.element}"`); code.push(`await page.${await generateLocator(locator)}.fill(${javascript.quote(params.text)});`); steps.push(() => locator.fill(params.text)); } if (params.submit) { code.push(`// Submit text`); code.push(`await page.${await generateLocator(locator)}.press('Enter');`); steps.push(() => locator.press('Enter')); } return { code, action: () => steps.reduce((acc, step) => acc.then(step), Promise.resolve()), captureSnapshot: true, waitForNetwork: true, }; },
  • Schema definition for the 'browser_type' tool using Zod, defining input parameters: element and ref (inherited), text (required), submit and slowly (optional).
    const typeSchema = elementSchema.extend({ text: z.string().describe('Text to type into the element'), submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'), slowly: z.boolean().optional().describe('Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.'), }); const type = defineTool({ capability: 'core', schema: { name: 'browser_type', title: 'Type text', description: 'Type text into editable element', inputSchema: typeSchema, type: 'destructive', },
  • Registration of the 'browser_type' tool (named 'type' variable) in the module's default export array of tools.
    export default [ snapshot, click, drag, hover, type, selectOption, ];
  • src/tools.ts:35-50 (registration)
    Higher-level registration including the snapshot tools module (which contains 'browser_type') in the snapshotTools array used likely for tool registration in the MCP server.
    export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Angeluis001/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server