browser_wait_for_element
Wait for a specified web element to appear using a selector and optional timeout. Supports parallel browser instances in the Concurrent Browser MCP server for efficient automation.
Instructions
Wait for an element to appear
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceId | Yes | Instance ID | |
| selector | Yes | Element selector | |
| timeout | No | Timeout in milliseconds |
Implementation Reference
- src/tools.ts:935-955 (handler)The main handler function for 'browser_wait_for_element' that waits for a selector using Playwright's page.waitForSelector.private async waitForElement(instanceId: string, selector: string, timeout: number): Promise<ToolResult> { const instance = this.browserManager.getInstance(instanceId); if (!instance) { return { success: false, error: `Instance ${instanceId} not found` }; } try { await instance.page.waitForSelector(selector, { timeout }); return { success: true, data: { selector, found: true }, instanceId }; } catch (error) { return { success: false, error: `Wait for element failed: ${error instanceof Error ? error.message : error}`, instanceId }; } }
- src/tools.ts:569-570 (registration)Dispatch/registration of the tool handler in the executeTools switch statement.case 'browser_wait_for_element': return await this.waitForElement(args.instanceId, args.selector, args.timeout || 30000);
- src/tools.ts:398-419 (schema)Tool schema and registration definition returned by getTools(), including name, description, and inputSchema.name: 'browser_wait_for_element', description: 'Wait for an element to appear', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, selector: { type: 'string', description: 'Element selector', }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 } }, required: ['instanceId', 'selector'] } },