click_element
Automate web interactions by clicking elements using CSS selectors with AutoProbeMCP. Specify a selector and optional timeout to interact with web pages programmatically.
Instructions
Click on an element by CSS selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element to click | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/index.ts:483-499 (handler)Handler for the 'click_element' tool. Validates input parameters using ClickElementSchema, performs a click on the specified selector using Playwright's page.click method with optional timeout, and returns a confirmation message.case 'click_element': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = ClickElementSchema.parse(args); await currentPage.click(params.selector, { timeout: params.timeout }); return { content: [ { type: 'text', text: `Clicked element: ${params.selector}` } ] }; }
- src/index.ts:28-31 (schema)Zod schema defining the input parameters for the click_element tool: selector (required string) and timeout (optional number, default 5000ms).const ClickElementSchema = z.object({ selector: z.string(), timeout: z.number().default(5000) });
- src/index.ts:177-195 (registration)Tool registration in the list_tools response, providing name, description, and inputSchema matching the Zod schema.{ name: 'click_element', description: 'Click on an element by CSS selector', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to click' }, timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds' } }, required: ['selector'] } },