Skip to main content
Glama

wait_for

Pauses automation until specified text appears on a webpage, using Chrome DevTools to synchronize actions with page content loading.

Instructions

Wait for the specified text to appear on the selected page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to appear on the page
timeoutNoMaximum wait time in milliseconds. If set to 0, the default timeout will be used.

Implementation Reference

  • The handler function for the 'wait_for' tool. It waits for an element containing the specified text to appear on the page by creating locators in all frames using text and ARIA selectors, then calls wait() on the locator.
    handler: async (request, response, context) => { const page = context.getSelectedPage(); const frames = page.frames(); const locator = Locator.race( frames.flatMap(frame => [ frame.locator(`aria/${request.params.text}`), frame.locator(`text/${request.params.text}`), ]), ); if (request.params.timeout) { locator.setTimeout(request.params.timeout); } await locator.wait(); response.appendResponseLine( `Element with text "${request.params.text}" found.`, ); response.setIncludeSnapshot(true); },
  • The input schema for the 'wait_for' tool, defining the 'text' parameter and optional 'timeout'.
    schema: { text: z.string().describe('Text to appear on the page'), ...timeoutSchema, },
  • src/main.ts:307-320 (registration)
    The tools from snapshotTools (including wait_for) are collected into an array and registered via registerTool, which sets up the MCP server tool handler.
    const tools = [ ...Object.values(consoleTools), ...Object.values(emulationTools), ...Object.values(inputTools), ...Object.values(networkTools), ...Object.values(pagesTools), ...Object.values(performanceTools), ...Object.values(screenshotTools), ...Object.values(scriptTools), ...Object.values(snapshotTools), ]; for (const tool of tools) { registerTool(tool as unknown as ToolDefinition); }
  • src/main.ts:38-38 (registration)
    Import of snapshot tools module, which exports the wait_for tool.
    import * as snapshotTools from './tools/snapshot.js';

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/SHAY5555-gif/chrome-devtools-mcp'

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