Skip to main content
Glama

browser_click_text

Click webpage elements by text content during security testing. This tool automates browser interactions for penetration testing of web applications.

Instructions

Click an element on the page by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to click

Implementation Reference

  • Handler implementation for the 'browser_click_text' tool. Locates an element by text content using Playwright's page.getByText() and clicks it, with comprehensive error handling including retry for strict mode violations.
    case ToolName.BrowserClickText:
      try {
        await page.getByText(args.text).click();
        return {
          content: [{
            type: "text",
            text: `Clicked element with text: ${args.text}`,
          }],
          isError: false,
        };
      } catch (error) {
        if((error as Error).message.includes("strict mode violation")) {
            console.log("Strict mode violation, retrying on first element...");
            try {
                await page.getByText(args.text).first().click();
                return {
                    content: [{
                        type: "text",
                        text: `Clicked element with text: ${args.text}`,
                    }],
                    isError: false,
                };
            } catch (error) {
                return {
                    content: [{
                        type: "text",
                        text: `Failed (twice) to click element with text ${args.text}: ${(error as Error).message}`,
                    }],
                    isError: true,
                };
            }
        }
        return {
          content: [{
            type: "text",
            text: `Failed to click element with text ${args.text}: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • Input schema and metadata for the 'browser_click_text' tool, defining a required 'text' parameter of type string.
    {
      name: ToolName.BrowserClickText,
      description: "Click an element on the page by its text content",
      inputSchema: {
        type: "object",
        properties: {
          text: { type: "string", description: "Text content of the element to click" },
        },
        required: ["text"],
      },
    },
  • index.ts:26-26 (registration)
    Enum registration of the tool name 'browser_click_text' as ToolName.BrowserClickText, used throughout the codebase for tool identification.
    BrowserClickText = "browser_click_text",
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. It lacks details on behavioral traits such as error handling (e.g., if text isn't found), interaction effects (e.g., page navigation or state changes), performance considerations, or any side effects. 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 that directly conveys the core functionality without any fluff. It is appropriately sized and front-loaded, making it easy to parse quickly.

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 mutation nature (clicking implies interaction), lack of annotations, and no output schema, the description is insufficient. It doesn't cover expected outcomes, error cases, or how it integrates with sibling tools, leaving significant gaps for an AI agent to use it correctly in context.

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%, with the single parameter 'text' fully documented in the schema. The description adds no additional meaning beyond implying text content is used for element targeting, which aligns with the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Click') and target ('an element on the page by its text content'), making the purpose immediately understandable. It distinguishes from generic 'browser_click' by specifying text-based targeting, though it doesn't explicitly contrast with 'browser_hover_text' or 'browser_select_text'.

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_click' (for other selectors), 'browser_hover_text' (for hovering), or 'browser_select_text' (for selecting). The description implies usage for text-based clicking but offers no context on prerequisites, limitations, or sibling tool distinctions.

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/9olidity/MCP-Server-Pentest'

If you have feedback or need assistance with the MCP directory API, please join our Discord server