Skip to main content
Glama

browser_find_elements

Locate multiple web elements using Selenium WebDriver with strategies like CSS, XPath, or ID for browser automation and testing.

Instructions

Find multiple elements

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

  • Registration of the 'browser_find_elements' MCP tool, including inline handler function that uses ElementService to find elements and returns a success/error message.
    server.tool(
      'browser_find_elements',
      'Find multiple elements',
      { ...locatorSchema },
      async ({ by, value, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const elementService = new ElementService(driver);
          const elements = await elementService.findElements({
            by,
            value,
            timeout,
          });
          return {
            content: [{ type: 'text', text: `Found ${elements.length} elements` }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error finding elements: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Zod schema definition for locator parameters (by, value, timeout) used in the browser_find_elements 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'),
    };
  • ElementService.findElements method: core logic to wait for and find multiple elements using Selenium WebDriver.
    async findElements(params: LocatorParams): Promise<WebElement[]> {
      const locator = LocatorFactory.createLocator(params.by, params.value);
      await this.driver.wait(until.elementsLocated(locator), params.timeout || 15000);
      return this.driver.findElements(locator);
    }
  • LocatorFactory.createLocator: utility to create Selenium By locator objects based on strategy.
    static createLocator(by: LocatorStrategy, value: string): Locator {
      switch (by.toLowerCase()) {
        case 'id':
          return By.id(value);
        case 'css':
          return By.css(value);
        case 'xpath':
          return By.xpath(value);
        case 'name':
          return By.name(value);
        case 'tag':
          return By.css(value);
        case 'class':
          return By.className(value);
        case 'link':
          return By.linkText(value);
        case 'partialLink':
          return By.partialLinkText(value);
        default:
          throw new Error(`Unsupported locator strategy: ${by}`);
      }
    }
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Find multiple elements' gives no information about what happens when elements are found (e.g., returns a list, handles errors if none are found), whether it's a read-only operation, performance implications, or interaction with the browser state. The description is too vague to inform the agent about behavioral traits.

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

Conciseness2/5

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

While the description is concise with only three words, it's under-specified rather than efficiently informative. It fails to front-load critical information and doesn't earn its place by adding value beyond the tool name. Conciseness should not come at the cost of clarity, making this score low due to lack of substance.

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 explain what the tool returns (e.g., a list of element identifiers or details), how it behaves in edge cases, or its role in the broader context of sibling browser tools. For a tool that likely interacts with dynamic web content, more context is needed.

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 documentation for all parameters ('by', 'value', 'timeout'), including an enum for 'by'. The description adds no additional semantic information beyond what's in the schema. According to the rules, with high schema coverage (>80%), the baseline score is 3 even with no param info in the description, which applies here.

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 multiple elements' is a tautology that essentially restates the tool name 'browser_find_elements'. It doesn't specify what kind of elements (e.g., DOM elements in a web page) or provide any distinguishing context from sibling tools like 'browser_find_element' (singular). The description lacks the specificity needed to understand the tool's exact function beyond its name.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'browser_find_element' (singular) for finding a single element, nor does it explain scenarios where finding multiple elements is preferred (e.g., for batch operations or when expecting multiple matches). There's no context about prerequisites, dependencies, or typical use cases.

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