page_waitTimeout
Delay automation by a specified number of milliseconds to allow page elements to load or stabilize in WeChat mini program testing.
Instructions
等待指定的毫秒数。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | ||
| milliseconds | Yes |
Implementation Reference
- src/tools/page.ts:271-289 (handler)The handler function for the 'page_waitTimeout' tool. It waits a specified number of milliseconds using page.waitFor().
function createWaitForTimeoutTool(manager: WeappAutomatorManager): AnyTool { return { name: "page_waitTimeout", description: "等待指定的毫秒数。", parameters: waitForTimeoutParameters, execute: async (rawArgs, context: ToolContext) => withUserErrorResult(async () => { const args = waitForTimeoutParameters.parse(rawArgs ?? {}); return manager.withPage<ContentResult>( context.log, { overrides: args.connection }, async (page) => { await page.waitFor(args.milliseconds); return toTextResult(`已等待 ${args.milliseconds}ms。`); } ); }), }; } - src/tools/page.ts:37-39 (schema)Zod schema for the 'page_waitTimeout' tool. Defines a required 'milliseconds' (nonnegative integer) parameter, plus optional 'connection' overrides.
const waitForTimeoutParameters = connectionContainerSchema.extend({ milliseconds: z.coerce.number().int().nonnegative(), }); - src/tools/page.ts:52-62 (registration)Registration of the 'page_waitTimeout' tool among other page tools in the createPageTools factory function.
export function createPageTools(manager: WeappAutomatorManager): AnyTool[] { return [ createGetElementTool(manager), createGetElementsTool(manager), createWaitForElementTool(manager), createWaitForTimeoutTool(manager), createGetPageDataTool(manager), createSetPageDataTool(manager), createCallPageMethodTool(manager), ]; } - src/tools/common.ts:15-17 (helper)The connectionContainerSchema used by the tool's schema for optional connection overrides.
export const connectionContainerSchema = z.object({ connection: connectionOverridesSchema.optional(), }); - src/tools/common.ts:61-70 (helper)The toTextResult helper used to format the success message returned by the tool.
export function toTextResult(text: string): ContentResult { return { content: [ { type: "text", text, }, ], }; }