Skip to main content
Glama

wait_for_navigation

Wait for a web page to complete navigation to a new URL before proceeding with automated browser tasks, ensuring content is fully loaded.

Instructions

Wait for the page to navigate to a new URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
waitUntilNo
timeoutNoTimeout in milliseconds
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Handler implementation for the wait_for_navigation tool. Gets the page for the specified tab, waits for navigation with optional waitUntil and timeout, returns the new URL and title on success, or handles errors like timeout.
    server.tool( 'wait_for_navigation', 'Wait for the page to navigate to a new URL', waitForNavigationSchema.shape, async ({ waitUntil, timeout, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; const timeoutMs = timeout ?? getDefaultTimeout(); try { await page.waitForNavigation({ waitUntil: (waitUntil ?? 'load') as WaitUntilOption, timeout: timeoutMs, }); return handleResult(ok({ url: page.url(), title: await page.title(), })); } catch (error) { if (error instanceof Error && error.message.includes('timeout')) { return handleResult(err(operationTimeout('wait_for_navigation', timeoutMs))); } return handleResult(err(normalizeError(error))); } } );
  • Zod schema for validating input to the wait_for_navigation tool, including optional waitUntil, timeout, and tabId parameters.
    export const waitForNavigationSchema = z.object({ waitUntil: waitUntilSchema, timeout: timeoutSchema, tabId: tabIdSchema, });
  • src/server.ts:26-26 (registration)
    High-level registration call that invokes the function to register the wait_for_navigation tool (among other waiting tools).
    registerWaitingTools(server);

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/andytango/puppeteer-mcp'

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