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
| Name | Required | Description | Default |
|---|---|---|---|
| role | No | 元素角色:button/link/input/textbox/checkbox/radio/combobox 等(可选) | |
| text | Yes | 要查找的元素文本 | |
| limit | No | 返回数量,默认 5 | |
| tagName | No | 标签名过滤,如 button/a/input/div 等(可选) | |
| onlyVisible | No | 只返回可见元素,默认 true |