Skip to main content
Glama

browser_select_text

Select dropdown elements by text content during web application penetration testing to automate security vulnerability detection.

Instructions

Select an element on the page with Select tag by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to select
valueYesValue to select

Implementation Reference

  • The handler function for 'browser_select_text' tool. It uses Playwright to select an option in a dropdown by finding the select element via text and selecting the specified value, with try-catch error handling and retry logic for strict mode violations.
    case ToolName.BrowserSelectText: try { await page.getByText(args.text).selectOption(args.value); return { content: [{ type: "text", text: `Selected element with text ${args.text} with value: ${args.value}`, }], 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().selectOption(args.value); return { content: [{ type: "text", text: `Selected element with text ${args.text} with value: ${args.value}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed (twice) to select element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; } } return { content: [{ type: "text", text: `Failed to select element with text ${args.text}: ${(error as Error).message}`, }], isError: true, }; }
  • The input schema definition for the 'browser_select_text' tool, specifying required parameters 'text' and 'value'.
    { name: ToolName.BrowserSelectText, description: "Select an element on the page with Select tag by its text content", inputSchema: { type: "object", properties: { text: { type: "string", description: "Text content of the element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["text", "value"], },
  • index.ts:840-842 (registration)
    Registration of the tools list handler, which exposes the TOOLS array containing the 'browser_select_text' tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));
  • index.ts:844-846 (registration)
    Registration of the call tool request handler, which dispatches tool calls (including 'browser_select_text') to the handleToolCall function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name as ToolName, request.params.arguments ?? {}) );
  • Enum constant definition mapping BrowserSelectText to the tool name string 'browser_select_text'.
    BrowserSelectText = "browser_select_text",

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