Skip to main content
Glama

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
NameRequiredDescriptionDefault
refNoElement ref or CSS selector to wait for
stateNoWhat to wait for
timeoutNoTimeout in milliseconds (default: 15000)

Implementation Reference

  • 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 };
        }
      }
    );
  • The tool 'pilot_wait' is registered in the list of core tools.
    'pilot_wait',

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TacosyHorchata/Pilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server