Skip to main content
Glama

page_getElements

Retrieve multiple page elements by CSS selector, returning an array with details such as index, tagName, text, and size. Supports limiting results and appending outer WXML.

Instructions

通过选择器获取页面元素数组,相当于 page.$$(selector)。返回 {selector,count,totalCount,limited,elements:[{index,tagName,text,value,size,offset}]};limit 默认/最大 100,避免大页面一次汇总所有元素卡住连接;totalCount 是总命中数,count 是实际返回数。无匹配时返回 count:0 的空列表(不抛错,这是与会抛错的 page_getElement 的关键区别——批量/计数用本工具,单个必存在的元素用 page_getElement)。withWxml=true 给每个元素附完整 outerWxml。支持 selector[index=N](0 基)只取第 N 个。⚠️ page.$$ 默认不穿透自定义组件(是否穿透取决于组件 styleIsolation/addGlobalClass,可用 page_getElements 看实际命中数判断);组件内部元素用 element_getInnerElements,或 element_* 工具的 selector(组件)+innerSelector(内部)。结果超过 maxBytes(默认 50000B)返回截断包装。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
maxBytesNo
selectorYes
withWxmlNo
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?

Without annotations, the description fully covers behavior: returns empty list on no match (no error), default limit and maximum, totalCount vs count, withWxml behavior, selector[index=N] syntax, maxBytes truncation, and penetration limitations of page.$$.

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 dense but well-structured, front-loading the main purpose and return structure. It covers many details without redundancy, though it could be slightly shorter.

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, the description fully details the return format including all fields. It covers edge cases (no match, truncation) and links to sibling tools for component penetration. Complete and actionable.

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?

Despite low schema coverage (20%), the description explains all parameters: limit (default 100, max 100, reason), maxBytes (default 50000B, truncation), withWxml, connection (optional override), and selector (with special syntax). Adds context and examples beyond 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?

Clearly states it retrieves an array of page elements by selector, equivalent to page.$$(selector). Distinguishes from sibling page_getElement by noting that this tool returns an empty list on no match while the other throws an error.

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?

Explicitly advises when to use this tool (batch/count) vs page_getElement (single required element). Also explains that page.$$ does not penetrate custom components and directs users to element_getInnerElements for that case.

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