Skip to main content
Version: 23.5.0

Frame.select() 方法

¥Frame.select() method

在第一个 <select> 元素上选择与 selector 匹配的一组值。

¥Selects a set of value on the first <select> element that matches the selector.

签名

¥Signature

class Frame {
select(selector: string, ...values: string[]): Promise<string[]>;
}

参数

¥Parameters

范围

类型

描述

selector

string

要查询的选择器。

values

string[]

要选择的值的数组。如果 <select> 具有 multiple 属性,则考虑所有值,否则仅考虑第一个值。

Returns:

Promise<string[]>

成功选择的值的列表。

¥the list of values that were successfully selected.

异常

¥Exceptions

如果没有 <select>selector 匹配,则抛出异常。

¥Throws if there's no <select> matching selector.

示例

¥Example

frame.select('select#colors', 'blue'); // single selection
frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections