browser_select
Automates selection of elements in web pages using CSS selectors, enabling precise interaction for penetration testing and vulnerability detection in web applications.
Instructions
Select an element on the page with Select tag using CSS selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for element to select | |
| value | Yes | Value to select |
Implementation Reference
- index.ts:383-422 (handler)Handler implementation for the 'browser_select' tool. Selects an option in a select element using a CSS selector and value, with retry logic for strict mode violations.case ToolName.BrowserSelect: try { await page.locator(args.selector).selectOption(args.value); return { content: [{ type: "text", text: `Selected ${args.selector} with: ${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.locator(args.selector).first().selectOption(args.value); return { content: [{ type: "text", text: `Selected ${args.selector} with: ${args.value}`, }], isError: false, }; } catch (error) { return { content: [{ type: "text", text: `Failed (twice) to select ${args.selector}: ${(error as Error).message}`, }], isError: true, }; } } return { content: [{ type: "text", text: `Failed to select ${args.selector}: ${(error as Error).message}`, }], isError: true, }; }
- index.ts:109-120 (registration)Registration of the 'browser_select' tool in the TOOLS array, including name, description, and input schema definition.{ name: ToolName.BrowserSelect, description: "Select an element on the page with Select tag using CSS selector", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["selector", "value"], }, },
- index.ts:112-119 (schema)Input schema for the 'browser_select' tool, defining parameters 'selector' and 'value'.inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to select" }, value: { type: "string", description: "Value to select" }, }, required: ["selector", "value"], },