Skip to main content
Glama

browser_find_element

Locate visible DOM elements on a page by matching text or ARIA role using multiple strategies. Returns CSS selectors ranked by confidence.

Instructions

Smart element locator: find visible DOM elements by text description or ARIA role using multi-strategy matching (exact text > contains text > placeholder > aria-label > title/alt > fuzzy), returning CSS selectors and confidence scores sorted by score desc.

中文详情:

  • 用途:按自然语言文本描述或角色智能定位页面元素,返回 CSS 选择器、置信度和元素信息

  • 何时使用:不知道选择器但知道按钮文案时;UI 文案变化后定位元素时;批量自动化脚本根据文案定位时;测试无 id/name 属性的元素时

  • 输出:{ ok: boolean, results: array, total: number } — 每项含 { selector, text, role, tagName, confidence, visible }

  • 参数:

    • text (string, 必填):要查找的元素文本

    • role (string, 可选):元素角色,如 button/link/input/textbox/checkbox/radio/combobox

    • tagName (string, 可选):标签名过滤,如 button/a/input/div

    • onlyVisible (boolean, 可选):只返回可见元素,默认 true

    • limit (number, 可选):返回数量,默认 5

  • 错误:无匹配元素返回空数组但 ok=true;text 为空抛出 'Text is required'

  • 示例:{"text":"提交","role":"button","limit":3}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roleNo元素角色:button/link/input/textbox/checkbox/radio/combobox 等(可选)
textYes要查找的元素文本
limitNo返回数量,默认 5
tagNameNo标签名过滤,如 button/a/input/div 等(可选)
onlyVisibleNo只返回可见元素,默认 true
Behavior4/5

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

Since no annotations are provided, the description carries full burden. It discloses the matching strategy hierarchy (exact text > contains text > placeholder > aria-label > title/alt > fuzzy), error handling (empty array with ok=true for no match, error for empty text), and the return structure with confidence scores and visibility flag. This is comprehensive, though it could mention potential side effects or performance impacts.

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 well-structured with sections for matching strategy, usage, output, parameters, errors, and examples. It is concise but includes both English and Chinese text, which may be redundant for an English-only agent. Nevertheless, every part adds useful information, and it is not overly verbose.

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?

Despite no output schema, the description fully explains the return format ({ ok, results, total }) and the content of each result item. It covers all necessary aspects: purpose, matching strategy, parameter details, error handling, and an example. For a tool with 5 parameters and no annotations, this is complete and well-suited for an AI agent to use 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?

The input schema already covers all parameters with descriptions (100% coverage), so baseline is 3. The description adds value by specifying default values for onlyVisible (true) and limit (5), clarifying the role parameter values with examples, and adding error handling info for the text parameter. This extra context justifies a score of 4.

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 the tool's purpose as a 'Smart element locator' that finds visible DOM elements by text or ARIA role, using a multi-strategy matching approach. It distinguishes itself from sibling tools like browser_click or browser_find by specifying that it returns CSS selectors with confidence scores, and it is intended for cases where the selector is unknown but the text is known.

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 explicit when-to-use scenarios in Chinese: when selector is unknown but button text is known, when UI text changes, for batch automation, and for testing elements without id/name. Although it doesn't explicitly state when not to use it, the given contexts are clear and helpful for the agent to decide.

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/validpilot/ai-verify-mcp'

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