Skip to main content
Glama

browser_element_is_selected

Check if a web element is selected using locator strategies like ID, CSS, or XPath to verify element states during browser automation testing.

Instructions

Checks if an element is selected

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

  • Registration of the 'browser_element_is_selected' MCP tool, including input schema reference and inline handler function that delegates to ElementService.
    server.tool( 'browser_element_is_selected', 'Checks if an element is selected', { ...locatorSchema }, async ({ by, value, timeout = 15000 }) => { try { const driver = stateManager.getDriver(); const elementService = new ElementService(driver); const isSelected = await elementService.isElementSelected({ by, value, timeout, }); return { content: [{ type: 'text', text: `Element is selected: ${isSelected}` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error checking element selected status: ${(e as Error).message}`, }, ], }; } } );
  • Handler logic for checking if the located browser element is selected, using Selenium WebElement.isSelected().
    async isElementSelected(params: LocatorParams): Promise<boolean> { try { const element = await this.findElement(params); return element.isSelected(); } catch { return false; } }
  • Zod schema defining the input parameters (locator strategy, value, optional timeout) for element-related tools.
    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'), };
  • TypeScript interface for LocatorParams used in ElementService methods and schema.
    export interface LocatorParams {

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