Skip to main content
Glama

等待页面条件成立

wait_for

Wait for a page element to appear or a JavaScript expression to become true before continuing, preventing operations on asynchronously rendered SPA content.

Instructions

在页面上轮询等待条件成立后再返回,避免 SPA 异步渲染导致「元素还没出来就操作」。两种条件二选一:selector(元素出现;absent=true 时改为等待其消失)或 code(返回真值的 JS 表达式,支持 await)。超时仍未满足则报错。轮询间隔 200ms。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNo与 selector 二选一:返回真值即认为条件成立的 JS 表达式(如 `fetch('/api').then(r=>r.data)`),支持 await
noteNo操作说明:展示给页面用户的自然语言描述(用户会在页面气泡的操作记录里看到),用用户的语言填写,建议始终提供
absentNo配合 selector:true 表示等待元素消失(默认 false 等待出现)
pageIdNo目标页面 id(单页时可省略)
selectorNo要等待的 CSS 选择器(深度查询,穿 shadow DOM);absent=true 时等待其消失
timeoutMsNo超时毫秒数,默认 10000,上限 120000
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral burden and does it well: it discloses polling interval (200ms), timeout error behavior, the mutual exclusivity of selector/code, and how absent=true changes the condition. This is substantial operational context for a waiting primitive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each earning its place: the purpose and use case, the two condition modes, then timeout and polling details. Information is front-loaded and there is zero filler or repetition of schema content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is nearly complete for a wait tool: it explains what, when, how, and failure behavior. Minor gaps are the undefined return value and unspecified behavior if both selector and code are supplied, but these are low-stakes for a synchronization tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so each parameter is already clearly documented. The description adds value by explaining the mutual-exclusion rule and the polling cadence, but it does not add per-parameter meaning beyond the schema—hence the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: polling/waiting on the page until a condition holds before returning. It clearly distinguishes itself from imperative siblings like click, type, or eval_js by framing the tool as a synchronization/readiness check.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The opening sentence gives a concrete use case—avoiding operations before SPA async rendering finishes—which tells an agent when to reach for this tool. It does not explicitly name alternatives or exclusion cases, but the context is specific enough to guide selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/kirakiray/web-bridge-mcp'

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