Skip to main content
Glama

browser_clear

Clear input field values in web browsers using locator strategies like ID, CSS, or XPath to reset form fields or remove text from input elements.

Instructions

Clears the value of an input element

Input Schema

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

Implementation Reference

  • Registers the browser_clear tool, including its description, input schema (locatorSchema), and handler function that instantiates ElementService and calls clearElement.
    server.tool( 'browser_clear', 'Clears the value of an input element', { ...locatorSchema }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); await elementService.clearElement({ by, value, timeout }); return { content: [{ type: 'text', text: 'Element cleared' }], }; } catch (e) { return { content: [ { type: 'text', text: `Error clearing element: ${(e as Error).message}`, }, ], }; } } );
  • Zod schema defining the input parameters for browser_clear: locator strategy (by), value, and optional timeout.
    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'), };
  • The core handler logic in ElementService.clearElement: finds the element using the locator and calls Selenium's clear() method on it.
    async clearElement(params: LocatorParams): Promise<void> { const element = await this.findElement(params); await element.clear(); }

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