browser_blur_element
Remove focus from web page elements during automation testing to simulate user interactions and validate UI behavior without active selection.
Instructions
Remove focus from a specific element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | Yes | Locator strategy to find element | |
| value | Yes | Value for the locator strategy | |
| timeout | No | Maximum time to wait for element in milliseconds |
Implementation Reference
- src/services/actionService.ts:103-107 (handler)Core implementation that locates the element using the provided locator and executes JavaScript to remove focus (blur) from it using Selenium WebDriver.async blurElement(params: LocatorParams): Promise<void> { const locator = LocatorFactory.createLocator(params.by, params.value); const element = await this.driver.wait(until.elementLocated(locator), params.timeout || 15000); await this.driver.executeScript('arguments[0].blur();', element); }
- src/tools/actionTools.ts:458-481 (registration)Registers the MCP tool 'browser_blur_element' with the server, defining its description, input schema (locator), and handler function that instantiates ActionService and calls blurElement.server.tool( 'browser_blur_element', 'Remove focus from a specific element', { ...locatorSchema }, async ({ by, value }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.blurElement({ by, value }); return { content: [{ type: 'text', text: `Removed focus from element` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error removing focus from element: ${(e as Error).message}`, }, ], }; } } );
- src/types/index.ts:29-35 (schema)Zod schema defining the input parameters for locating elements (by strategy, value, optional timeout), used in the tool's input validation.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'), };
- src/tools/index.ts:11-11 (registration)Calls registerActionTools within registerAllTools, which includes the registration of browser_blur_element among other action tools.registerActionTools(server, stateManager);