Skip to main content
Glama

browser_element_is_selected

Check if a web element is selected using Selenium WebDriver. Specify locator strategy and value to verify selection state for testing and automation.

Instructions

Checks if an element is selected

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

  • Registers the 'browser_element_is_selected' MCP tool, providing the schema and a thin async handler that instantiates ElementService and calls its isElementSelected method, returning formatted text response.
    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}`,
              },
            ],
          };
        }
      }
    );
  • Core helper method in ElementService that finds the element using locator params and checks if it is selected via Selenium WebElement.isSelected(), returning false on error.
    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 for element locators (by, value, optional timeout), used by the tool.
    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'),
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'checks' something, implying a read-only operation, but doesn't clarify what 'selected' entails, whether it waits for the element to appear (hinted by the timeout parameter), or what happens if the element isn't found. This leaves critical behavioral aspects unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose, making it easy to parse quickly, though this conciseness comes at the cost of detail in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (checking element state with parameters) and lack of annotations or output schema, the description is incomplete. It doesn't explain what 'selected' means, what the return value indicates, or how errors are handled, leaving the agent with insufficient context for reliable use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema fully documents all parameters (by, value, timeout). The description adds no additional meaning beyond what the schema provides, such as explaining how 'selected' relates to the locator parameters or timeout behavior. The baseline score of 3 reflects adequate but minimal value addition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('checks') and resource ('an element'), making it immediately understandable. However, it doesn't differentiate itself from sibling tools like 'browser_element_is_displayed' or 'browser_element_is_enabled', which follow a similar pattern for checking element states.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't specify what 'selected' means in context (e.g., for checkboxes, radio buttons, or dropdown options) or mention sibling tools that check other element states, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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