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
| Name | Required | Description | Default |
|---|---|---|---|
| waitUntil | No | ||
| timeout | No | Timeout in milliseconds | |
| tabId | No | Tab ID to operate on (uses active tab if not specified) |
Implementation Reference
- src/tools/waiting.ts:63-93 (handler)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))); } } );
- src/schemas.ts:136-140 (schema)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);