wait_for_element
Wait for a UI element to appear in the DOM before proceeding, handling asynchronous page loading and dynamic content updates in Tauri desktop applications.
Instructions
Wait for an element to appear in the DOM. Useful for handling async UI states.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector to wait for | |
| timeout | No | Timeout in milliseconds. Default: 5000 |
Implementation Reference
- src/tools/interact.ts:59-78 (handler)The core handler function that executes the 'wait_for_element' tool logic. It calls the underlying TauriDriver's waitForElement method with the provided selector and optional timeout, then wraps the result in a standardized ToolResponse.export async function waitForElement( driver: TauriDriver, params: WaitForElementParams ): Promise<ToolResponse<{ message: string }>> { try { await driver.waitForElement(params.selector, params.timeout); return { success: true, data: { message: `Element found: ${params.selector}`, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error), }; } }
- src/index.ts:139-157 (registration)The tool registration in the ListTools response, defining the name, description, and input schema for 'wait_for_element'.{ name: 'wait_for_element', description: 'Wait for an element to appear in the DOM. Useful for handling async UI states.', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector to wait for', }, timeout: { type: 'number', description: 'Timeout in milliseconds. Default: 5000', default: 5000, }, }, required: ['selector'], }, },
- src/types.ts:84-89 (schema)TypeScript interface defining the parameters for the wait_for_element tool, used by the handler function.export interface WaitForElementParams { /** CSS selector to wait for */ selector: string; /** Timeout in milliseconds */ timeout?: number; }
- src/index.ts:286-296 (handler)The dispatcher case in the CallToolRequest handler that invokes the waitForElement tool function and formats the MCP response.case 'wait_for_element': { const result = await waitForElement(driver, args as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }