Skip to main content
Glama

page_expectCount

Verify that the count of elements matching a selector exactly equals the expected number. Supports index-based selection and returns pass/fail result.

Instructions

一次性断言匹配选择器的元素数量是否「精确等于」expected(基于 page.$$,不是 >=)。支持 selector[index=N],此时命中该索引计 1、越界计 0。不抛错——结果在返回的 {pass,expected,actual,snapshot:{selector,index}} 的 pass 里,失败看 actual。⚠️ page.$$ 默认不穿透自定义组件(是否穿透取决于组件 styleIsolation/addGlobalClass,可用 page_getElements 看实际命中数判断),组件内部的元素不计入,会偏少。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expectedNo
selectorYes
connectionNo可选连接覆盖(不传则用默认会话)。可用字段:mode(launch|connect)、cliPath、projectPath、wsEndpoint、timeout、port(【自动化端口】→ cli auto --auto-port,默认 9420;不是 IDE HTTP 服务端口,别把 IDE 服务端口传进来)、account、ticket、trustProject、args、cwd、autoClose、autoLaunch、launchTimeout、connectTimeout。
Behavior5/5

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

With no annotations provided, the description fully discloses behavior: it does not throw errors, returns result in {pass,expected,actual,snapshot} format, and explains page.$$ limitations regarding custom components. The index behavior is also clearly documented.

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

Conciseness4/5

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

The description is one dense paragraph. It front-loads the core purpose and then covers nuances. While it is concise and contains no fluff, it could benefit from slight structuring (e.g., separate lines for usage vs. behavior).

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

Completeness5/5

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

Given no output schema and the complexity of the tool (selector indexing, custom component isolation, non-throwing behavior), the description is remarkably complete. It covers edge cases, return structure, and side effects, ensuring an agent can use it correctly.

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

Parameters4/5

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

Schema coverage is low (33%, only 'connection' has description). The description adds meaning for 'selector' (index syntax, page.$$ behavior) and 'expected' (exact count, not >=). For 'connection', the schema already has a detailed description, so no duplication needed. Overall, it compensates for missing schema descriptions.

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 explicitly states the tool asserts that the count of elements matching a selector exactly equals 'expected'. It uses specific verb ('断言...数量是否精确等于') and resource ('匹配选择器的元素'), distinguishing it from sibling tools like page_expectVisible or page_expectData.

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

Usage Guidelines5/5

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

It explains when to use: for exact count assertion, not >=. It details special selector syntax (selector[index=N]) and behavior (index out of bounds counts 0). It warns that page.$$ does not penetrate custom components, guiding the user to avoid inaccurate counts.

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/Chaixueyuan/weapp-agent-mcp'

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