pilot_wait
Wait for elements to become visible or hidden, for network activity to idle, or for pages to fully load during browser automation.
Instructions
Wait for element visibility, network idle, or page load.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Element ref or CSS selector to wait for | |
| state | No | What to wait for | |
| timeout | No | Timeout in milliseconds (default: 15000) |
Implementation Reference
- src/tools/interaction.ts:240-278 (handler)The handler implementation for the 'pilot_wait' tool, which uses Playwright to wait for page states or element visibility.
server.tool( 'pilot_wait', 'Wait for element visibility, network idle, or page load.', { ref: z.string().optional().describe('Element ref or CSS selector to wait for'), state: z.enum(['visible', 'hidden', 'networkidle', 'load']).optional().describe('What to wait for'), timeout: z.number().optional().describe('Timeout in milliseconds (default: 15000)'), }, async ({ ref, state, timeout }) => { await bm.ensureBrowser(); try { const page = bm.getPage(); const ms = timeout || 15000; if (state === 'networkidle') { await page.waitForLoadState('networkidle', { timeout: ms }); return { content: [{ type: 'text' as const, text: 'Network idle' }] }; } if (state === 'load') { await page.waitForLoadState('load', { timeout: ms }); return { content: [{ type: 'text' as const, text: 'Page loaded' }] }; } if (ref) { const resolved = await bm.resolveRef(ref); if ('locator' in resolved) { await resolved.locator.waitFor({ state: (state || 'visible') as any, timeout: ms }); } else { await page.waitForSelector(resolved.selector, { state: (state || 'visible') as any, timeout: ms }); } bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Element ${ref} is ${state || 'visible'}` }] }; } return { content: [{ type: 'text' as const, text: 'Nothing to wait for — provide ref or state' }], isError: true }; } catch (err) { bm.incrementFailures(); return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } ); - src/tools/register.ts:28-28 (registration)The tool 'pilot_wait' is registered in the list of core tools.
'pilot_wait',