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
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text content of the element to select | |
| value | Yes | Value to select |
Implementation Reference
- index.ts:424-463 (handler)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, }; }
- index.ts:121-131 (schema)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 ?? {}) );
- index.ts:29-29 (helper)Enum constant definition mapping BrowserSelectText to the tool name string 'browser_select_text'.BrowserSelectText = "browser_select_text",