get_element_text
Extract text content from a web element using a CSS selector with a customizable timeout via AutoProbeMCP's browser automation capabilities.
Instructions
Get text content of an element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/index.ts:544-560 (handler)Handler for the 'get_element_text' tool. Validates input with GetElementTextSchema, retrieves text content from the specified selector using Playwright's page.textContent method, and returns the text or '(empty)' if none.case 'get_element_text': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = GetElementTextSchema.parse(args); const text = await currentPage.textContent(params.selector, { timeout: params.timeout }); return { content: [ { type: 'text', text: `Element text: ${text || '(empty)'}` } ] }; }
- src/index.ts:44-47 (schema)Zod schema for validating input parameters of the get_element_text tool: selector (required string) and optional timeout (default 5000ms).const GetElementTextSchema = z.object({ selector: z.string(), timeout: z.number().default(5000) });
- src/index.ts:237-255 (registration)Tool registration in the listTools response, defining name, description, and inputSchema matching the Zod schema.{ name: 'get_element_text', description: 'Get text content of an element', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element' }, timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds' } }, required: ['selector'] } },