Skip to main content
Glama

browser_find_element

Locate web page elements using Selenium WebDriver for browser automation and testing. Specify locator strategies like ID, CSS, or XPath to find elements within a configurable timeout.

Instructions

Find an 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

  • The inline handler function for the browser_find_element tool. It retrieves the WebDriver, instantiates ElementService, calls findElement, and returns a success or error message.
    async ({ by, value, timeout = 15000 }) => {
      try {
        const driver = stateManager.getDriver();
        const elementService = new ElementService(driver);
        await elementService.findElement({ by, value, timeout });
        return {
          content: [{ type: 'text', text: 'Element found' }],
        };
      } catch (e) {
        return {
          content: [
            {
              type: 'text',
              text: `Error finding element: ${(e as Error).message}`,
            },
          ],
        };
      }
    }
  • The registration of the browser_find_element tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      'browser_find_element',
      'Find an element',
      { ...locatorSchema },
      async ({ by, value, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const elementService = new ElementService(driver);
          await elementService.findElement({ by, value, timeout });
          return {
            content: [{ type: 'text', text: 'Element found' }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error finding element: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • The locatorSchema defining the input parameters (by, value, timeout) for element location, used in the tool schema.
    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'),
    };
  • The findElement helper method in ElementService that creates a locator and waits for the element using Selenium WebDriver.
    async findElement(params: LocatorParams): Promise<WebElement> {
      const locator = LocatorFactory.createLocator(params.by, params.value);
      return this.driver.wait(until.elementLocated(locator), params.timeout || 15000);
    }
  • Higher-level registration function that calls registerElementTools, which registers the browser_find_element tool among others.
    export function registerAllTools(server: McpServer, stateManager: StateManager): void {
      registerBrowserTools(server, stateManager);
      registerElementTools(server, stateManager);
      registerActionTools(server, stateManager);
      registerCookieTools(server, stateManager);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden but offers no behavioral disclosure. It doesn't explain what happens if the element isn't found (e.g., returns null, throws error), whether it's a read-only operation, or any performance implications like timeouts. The description is too vague to inform the agent about how the tool behaves beyond the basic action implied by the name.

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 extremely concise with just two words, 'Find an element', which is front-loaded and wastes no space. While it's under-specified, it's not verbose or poorly structured, earning full marks for brevity and clarity within its limited scope.

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 complexity of a browser interaction tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, return values, or dependencies on other tools (e.g., requiring an open browser). For a tool with 3 parameters and no structured output documentation, this minimal description leaves significant gaps for the agent.

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 input schema has 100% description coverage, with clear parameter descriptions and an enum for 'by'. The description adds no additional meaning beyond what the schema provides, such as examples or usage context. However, with high schema coverage, the baseline score of 3 is appropriate as the schema adequately documents the parameters.

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

Purpose2/5

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

The description 'Find an element' is a tautology that restates the tool name 'browser_find_element' without adding specificity. It doesn't distinguish this from sibling tools like 'browser_find_elements' (plural) or 'browser_wait_for_element', nor does it specify what type of element or context (e.g., web page). This provides minimal value beyond the name itself.

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

Usage Guidelines1/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'browser_find_elements' (for multiple elements) or 'browser_wait_for_element' (for waiting), nor does it specify prerequisites such as requiring an open browser session. This leaves the agent without context for tool selection.

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