find_elements
Search iOS Simulator UI elements by text in labels, values, or hints to locate interface components for automation tasks.
Instructions
Search the UI tree for elements whose label, value, or hint contains query text
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Text to search for in labels/values/hints | |
| udid | No | Simulator UDID (optional, defaults to booted simulator) |
Implementation Reference
- src/index.ts:880-894 (handler)Implementation of the 'find_elements' MCP tool handler.
private async findElements(query: string, udid?: string) { const target = await resolveUdid(udid); try { const all = await this.fetchUiTree(target); const matches = findElementsByText(all, query); return { content: [{ type: 'text', text: JSON.stringify({ query, count: matches.length, elements: matches }, null, 2), }], }; } catch (error: any) { throw new McpError(ErrorCode.InternalError, `Failed to find elements: ${error.message}`); } } - src/index.ts:446-455 (registration)Registration of the 'find_elements' tool with its schema definition.
{ name: 'find_elements', description: 'Search the UI tree for elements whose label, value, or hint contains query text', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Text to search for in labels/values/hints' }, udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' }, }, required: ['query'],