browser_select
Select an option in a dropdown by value, label, or index. Enables form dropdown selection and validation in browser tests.
Instructions
Select an option in a dropdown by value, label text, or index.
中文详情:
用途:在下拉框(select 元素)中选择指定选项,支持按 value 值、按 label 文本、按索引三种方式
何时使用:表单下拉选项选择时;测试 select 联动效果时;筛选条件选择时;下拉框默认值验证时
输出:{ ok: boolean, selector: string, selectedValue: string, selectedLabel: string, selectedIndex: number, timestamp: string }
参数:
selector (string, 必填):select 元素的 CSS 选择器
value (string, 可选):要选择的 option 的 value 值
label (string, 可选):要选择的 option 的显示文本
index (number, 可选):要选择的 option 的索引(从 0 开始)
错误:selector 无匹配或非 select 元素抛出 'Not a select element';value/label/index 都未提供抛出 'No selection criteria provided';选项不存在抛出 'Option not found'
示例:{"selector":"#country","value":"cn"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | No | 要选择的option的索引(从0开始) | |
| label | No | 要选择的option的显示文本 | |
| value | No | 要选择的option的value值 | |
| selector | Yes | select元素的选择器 |