Skip to main content
Glama

page_waitElement

Waits for a specified selector element to appear on the page, ensuring elements are loaded before proceeding with automation tasks in WeChat Mini Program development.

Instructions

等待指定选择器的元素出现在页面上。注意:此方法不适用于自定义组件内部元素,仅能等待页面级别的元素。如需等待自定义组件内部元素,请使用 page_waitTimeout 配合 element 相关工具进行轮询检查。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionNo
selectorYes

Implementation Reference

  • The execute handler for the page_waitElement tool. Parses arguments, connects to the page via manager, calls page.waitFor with the selector, and returns a text confirmation.
    execute: async (rawArgs, context: ToolContext) => { const args = waitForElementParameters.parse(rawArgs ?? {}); return manager.withPage<ContentResult>( context.log, { overrides: args.connection }, async (page) => { await page.waitFor(args.selector); return toTextResult(`已等待元素选择器 "${args.selector}" 出现。`); } ); },
  • Zod schema defining the input parameters for the tool: a required 'selector' string, extended from connectionContainerSchema (likely including connection details).
    const waitForElementParameters = connectionContainerSchema.extend({ selector: z.string().trim().min(1), });
  • Factory function createPageTools that includes createWaitForElementTool(manager) in the returned array of page-related tools.
    export function createPageTools(manager: WeappAutomatorManager): AnyTool[] { return [ createGetElementTool(manager), createWaitForElementTool(manager), createWaitForTimeoutTool(manager), createGetPageDataTool(manager), createSetPageDataTool(manager), createCallPageMethodTool(manager), ]; }
  • src/tools.ts:7-13 (registration)
    Aggregate factory createTools that spreads createPageTools(manager), thus including the page_waitElement tool.
    export function createTools(manager: WeappAutomatorManager): AnyTool[] { return [ ...createApplicationTools(manager), ...createPageTools(manager), ...createElementTools(manager), ]; }
  • src/index.ts:17-17 (registration)
    Top-level registration where all tools, including page_waitElement, are added to the FastMCP server instance.
    server.addTools(createTools(manager));

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/yfmeii/weapp-dev-mcp'

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