Skip to main content
Glama

browser_clear

Clears input field values in web browsers for automated testing and form resetting. Use this Selenium WebDriver tool to remove text from text boxes, search bars, and form inputs during browser automation.

Instructions

Clears the value of an input element

Input Schema

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

Implementation Reference

  • Registration of the 'browser_clear' tool, including the inline handler function that invokes ElementService.clearElement to clear the input element.
    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}`, }, ], }; } }
  • Schema definition for locators used as input parameters for the browser_clear tool (by, value, 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'), };
  • Core handler logic for clearing the element using Selenium WebDriver's element.clear() method.
    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