wait
Pauses execution for a specified duration to allow web pages to finish loading or rendering dynamic content, ensuring complete page elements appear in screenshots.
Instructions
Use this tool when a page appears to be loading or not fully rendered. Common scenarios include: when elements are missing from a screenshot that should be there, when a page looks incomplete or broken, when dynamic content is still loading, or when a previous action (like clicking a button) hasn't fully processed yet. Waits for a specified number of seconds (up to 10) to allow the page to finish loading or rendering.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seconds | Yes | Number of seconds to wait (max 10). Start with a smaller value (2-3 seconds) and increase if needed. |
Implementation Reference
- src/index.ts:847-866 (handler)The handler function for the "wait" tool. Validates the seconds parameter (0-10), sleeps for the specified duration using the sleep utility, and returns a success message.async function handleWait(_page: Page, args: any): Promise<CallToolResult> { const { seconds } = args; if (typeof seconds !== "number" || seconds < 0 || seconds > 10) { return { isError: true, content: [ { type: "text", text: "Wait time must be a number between 0 and 10 seconds", }, ], }; } await sleep(seconds * 1000); // Reusing your sleep utility return { isError: false, content: [{ type: "text", text: `Waited ${seconds} second(s).` }], }; }
- src/index.ts:564-580 (schema)The schema definition for the "wait" tool in the TOOLS array, defining the input schema with a required 'seconds' number parameter (0-10).name: "wait", description: "Use this tool when a page appears to be loading or not fully rendered. Common scenarios include: when elements are missing from a screenshot that should be there, when a page looks incomplete or broken, when dynamic content is still loading, or when a previous action (like clicking a button) hasn't fully processed yet. Waits for a specified number of seconds (up to 10) to allow the page to finish loading or rendering.", inputSchema: { type: "object", properties: { seconds: { type: "number", description: "Number of seconds to wait (max 10). Start with a smaller value (2-3 seconds) and increase if needed.", minimum: 0, maximum: 10, }, }, required: ["seconds"], }, },
- src/index.ts:176-178 (helper)Helper utility function 'sleep' that pauses execution for a given number of milliseconds using setTimeout. Used by the wait handler.function sleep(ms: number): Promise<void> { return new Promise(resolve => setTimeout(resolve, ms)); }
- src/index.ts:937-939 (registration)Registration of the 'wait' tool handler in the main tool dispatcher switch statement within handleToolCall.case "wait": result = await handleWait(page, args); break;
- src/index.ts:1068-1070 (registration)Server handler for ListToolsRequestSchema that returns the TOOLS array, which includes the 'wait' tool definition.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, }));