Skip to main content
Glama

page_expectElementText

Assert element text against expected value using exact or substring matching. Returns pass status and actual text for efficient debugging.

Instructions

一次性断言元素文本(element.text(),含子节点渲染文本,非 input 的 value)是否匹配预期。mode='equals'(默认,整串精确相等) 或 'includes'(子串包含)。返回 {pass,expected,actual,snapshot:{selector,mode}}——读 pass,失败时看 actual 排查。结果超过 maxBytes(默认 50000B)会截断。⚠️ 与 page_expectVisible/Count 不同:元素不存在时本工具抛错(而非返回 pass:false)。支持 selector[index=N](0 基)。校验 input/textarea 的输入值请改走 element 取 value,不要用本工具。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoequals
expectedYes
maxBytesNo
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, the description fully covers behavioral traits: error on missing element (contrasting with siblings), result truncation beyond maxBytes, mode behavior, return object fields (pass, expected, actual, snapshot). It also warns against misuse for input values, ensuring the agent understands invocation constraints.

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 a single paragraph but front-loaded with main assertion and mode details. Every sentence adds value, covering return format, truncation, edge cases, and cautions. Slightly dense but not overly verbose; could be split for readability but still efficient.

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 5 parameters, no output schema, and no annotations, the description is exceptionally complete. It covers purpose, all parameters with semantics, behavioral traits (error on missing element, truncation), return structure, and usage guidelines for distinguishing from siblings. An agent can reliably invoke this tool based on the description alone.

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

Parameters5/5

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

Schema description coverage is low (20%). The description compensates thoroughly, explaining mode, expected, maxBytes purpose, and selector syntax (including index[N] usage). It adds practical meaning beyond the schema, especially for selector and mode, and clarifies that connection parameter's description is already in schema.

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 clearly states that the tool asserts element text matches expected, with specific details on mode (equals/includes) and contrast with page_expectVisible/Count for missing elements. It explicitly distinguishes from input value checking, making the purpose unambiguous.

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 description provides clear context for when to use (asserting element text) and when not to use (input/textarea values, recommending element.get value instead). It also explains mode options but lacks explicit 'use this tool when' vs 'use sibling when' structure, though behavioral contrasts with page_expectVisible/Count offer practical guidance.

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