Skip to main content
Glama

browser_type

Enter text into web form fields using various locator strategies to automate data input during browser automation tasks.

Instructions

Type into an editable field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesLocator strategy to find element
textYesText to enter into the element
timeoutNoMaximum time to wait for element in milliseconds
valueYesValue for the locator strategy

Implementation Reference

  • Registration of the browser_type tool, including inline handler that delegates to ElementService.sendKeysToElement and error handling.
    server.tool( 'browser_type', 'Type into an editable field', { ...locatorSchema, text: z.string().describe('Text to enter into the element'), }, async ({ by, value, text, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); await elementService.sendKeysToElement({ by, value, text, timeout }); return { content: [{ type: 'text', text: `Text "${text}" entered into element` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error entering text: ${(e as Error).message}`, }, ], }; } } );
  • Input schema for browser_type tool: locator params plus 'text' field.
    { ...locatorSchema, text: z.string().describe('Text to enter into the element'), },
  • Base locatorSchema used in browser_type and other element tools.
    export const locatorSchema = { by: z .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink']) .describe('Locator strategy to find element'), value: z.string().describe('Value for the locator strategy'), timeout: z.number().optional().describe('Maximum time to wait for element in milliseconds'), };
  • Helper method in ElementService that implements the core typing logic: find element, clear it, and send keys using Selenium WebDriver.
    async sendKeysToElement(params: LocatorParams & { text: string }): Promise<void> { const element = await this.findElement(params); await element.clear(); await element.sendKeys(params.text); }

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/pshivapr/selenium-mcp'

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