Skip to main content
Glama

browser_click

Click web elements using Selenium WebDriver by specifying locator strategies like ID, CSS, or XPath for browser automation and testing.

Instructions

Perform a click on 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

  • MCP tool handler for browser_click: instantiates ElementService and calls clickElement on the located element.
      async ({ by, value, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const elementService = new ElementService(driver);
          await elementService.clickElement({ by, value, timeout });
          return {
            content: [{ type: 'text', text: 'Element clicked' }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error clicking element: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Registration of the browser_click tool using server.tool in registerElementTools function.
    server.tool(
      'browser_click',
      'Perform a click on an element',
      { ...locatorSchema },
      async ({ by, value, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const elementService = new ElementService(driver);
          await elementService.clickElement({ by, value, timeout });
          return {
            content: [{ type: 'text', text: 'Element clicked' }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error clicking element: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • locatorSchema defining the input parameters (by, value, timeout) for element location in browser_click.
    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'),
    };
  • Core implementation of element click using Selenium WebDriver's element.click() after locating the element.
    async clickElement(params: LocatorParams): Promise<void> {
      const element = await this.findElement(params);
      await element.click();
    }
  • Invocation of registerElementTools which includes browser_click registration.
    registerElementTools(server, stateManager);
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits like whether it waits for element visibility, handles errors if element not found, requires the page to be loaded, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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 waste, clearly front-loading the core action. It's appropriately sized for a straightforward tool.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks information on behavioral aspects like error handling, success conditions, or interaction with the browser state, which are crucial for an AI agent to use this tool effectively.

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?

Schema description coverage is 100%, so the schema already documents all parameters (by, value, timeout) with descriptions and enums. The description adds no additional meaning beyond what the schema provides, such as examples or context for parameter usage, meeting the baseline for high schema coverage.

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 'Perform a click on an element' clearly states the action (click) and target (element), distinguishing it from non-click siblings like browser_type or browser_hover. However, it doesn't specify what type of click (e.g., left-click vs. right-click) or differentiate from browser_double_click and browser_right_click, which are explicit siblings.

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?

No guidance is provided on when to use this tool versus alternatives like browser_double_click or browser_right_click, or prerequisites such as needing an element to be visible or interactable. The description lacks context for usage decisions.

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