Skip to main content
Glama

browser_type

Enter text into web page input fields using Selenium WebDriver for browser automation and testing.

Instructions

Type into an editable field

Input Schema

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

Implementation Reference

  • Registration of the 'browser_type' MCP tool. Includes input schema (extending locatorSchema with 'text' field) and the handler function that retrieves the WebDriver, instantiates ElementService, and calls sendKeysToElement.
    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}`, }, ], }; } } );
  • Helper method in ElementService that implements the core typing logic: finds the target element using the locator, clears it, and sends the provided text 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); }
  • Base schema definition for element locators (by, value, timeout), which is spread into the browser_type tool's input schema.
    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'), };

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