browser_element_is_enabled
Check if a web element is enabled for interaction using Selenium WebDriver. Specify locator strategy and value to verify element state for automation testing.
Instructions
Checks if an element is enabled
Input 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/tools/elementTools.ts:236-263 (handler)Handler and registration for 'browser_element_is_enabled' tool. Instantiates ElementService and calls isElementEnabled method.
server.tool( 'browser_element_is_enabled', 'Checks if an element is enabled', { ...locatorSchema }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); const isEnabled = await elementService.isElementEnabled({ by, value, timeout, }); return { content: [{ type: 'text', text: `Element is enabled: ${isEnabled}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error checking element enabled status: ${(e as Error).message}`, }, ], }; } } ); - src/services/elementService.ts:59-66 (helper)ElementService.isElementEnabled: Finds the element using locator and returns WebElement.isEnabled() from Selenium, false on error.
async isElementEnabled(params: LocatorParams): Promise<boolean> { try { const element = await this.findElement(params); return element.isEnabled(); } catch { return false; } } - src/types/index.ts:29-35 (schema)Shared input schema for element locator tools: 'by' strategy, 'value', 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'), };