|
| 1 | +--- |
| 2 | +title: 'selectOption(selector, values[, options])' |
| 3 | +description: 'Browser module: frame.selectOption(selector, values[, options]) method' |
| 4 | +--- |
| 5 | + |
| 6 | +# selectOption(selector, values[, options]) |
| 7 | + |
| 8 | +{{% admonition type="warning" %}} |
| 9 | + |
| 10 | +Use locator-based [`locator.selectOption()`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/selectoption/) instead. |
| 11 | + |
| 12 | +{{% /admonition %}} |
| 13 | + |
| 14 | +Selects one or more options which match the values from a `<select>` element. |
| 15 | + |
| 16 | +<TableWithNestedRows> |
| 17 | + |
| 18 | +| Parameter | Type | Default | Description | |
| 19 | +| ------------------- | ---------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 20 | +| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. | |
| 21 | +| values | string or string[] or object | `''` | If the `select` has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. Object can be made up of keys with `value`, `label` or `index`. | |
| 22 | +| options | object | `null` | | |
| 23 | +| options.force | boolean | `false` | Setting this to `true` will bypass the actionability checks (`visible`, `stable`, `enabled`). | |
| 24 | +| options.noWaitAfter | boolean | `false` | If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete. | |
| 25 | +| options.strict | boolean | `false` | When `true`, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. | |
| 26 | +| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/). | |
| 27 | + |
| 28 | +</TableWithNestedRows> |
| 29 | + |
| 30 | +### Returns |
| 31 | + |
| 32 | +| Type | Description | |
| 33 | +| ------------------- | -------------------------------------------------------------- | |
| 34 | +| `Promise<string[]>` | A Promise that fulfills with the list of the selected options. | |
0 commit comments