Page.select_option This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in the ` ` element and selects these options. If the target elem
(
self,
selector: str,
value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
*,
index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None,
label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
element: typing.Optional[
typing.Union["ElementHandle", typing.Sequence["ElementHandle"]]
] = None,
timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
no_wait_after: typing.Optional[bool] = None,
force: typing.Optional[bool] = None,
strict: typing.Optional[bool] = None,
)
| 11996 | ) |
| 11997 | |
| 11998 | async def select_option( |
| 11999 | self, |
| 12000 | selector: str, |
| 12001 | value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 12002 | *, |
| 12003 | index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, |
| 12004 | label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 12005 | element: typing.Optional[ |
| 12006 | typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] |
| 12007 | ] = None, |
| 12008 | timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None, |
| 12009 | no_wait_after: typing.Optional[bool] = None, |
| 12010 | force: typing.Optional[bool] = None, |
| 12011 | strict: typing.Optional[bool] = None, |
| 12012 | ) -> typing.List[str]: |
| 12013 | """Page.select_option |
| 12014 | |
| 12015 | This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits |
| 12016 | until all specified options are present in the `<select>` element and selects these options. |
| 12017 | |
| 12018 | If the target element is not a `<select>` element, this method throws an error. However, if the element is inside |
| 12019 | the `<label>` element that has an associated |
| 12020 | [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used |
| 12021 | instead. |
| 12022 | |
| 12023 | Returns the array of option values that have been successfully selected. |
| 12024 | |
| 12025 | Triggers a `change` and `input` event once all the provided options have been selected. |
| 12026 | |
| 12027 | **Usage** |
| 12028 | |
| 12029 | ```py |
| 12030 | # Single selection matching the value or label |
| 12031 | await page.select_option(\"select#colors\", \"blue\") |
| 12032 | # single selection matching the label |
| 12033 | await page.select_option(\"select#colors\", label=\"blue\") |
| 12034 | # multiple selection |
| 12035 | await page.select_option(\"select#colors\", value=[\"red\", \"green\", \"blue\"]) |
| 12036 | ``` |
| 12037 | |
| 12038 | Parameters |
| 12039 | ---------- |
| 12040 | selector : str |
| 12041 | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be |
| 12042 | used. |
| 12043 | value : Union[Sequence[str], str, None] |
| 12044 | Options to select by value. If the `<select>` has the `multiple` attribute, all given options are selected, |
| 12045 | otherwise only the first option matching one of the passed options is selected. Optional. |
| 12046 | index : Union[Sequence[int], int, None] |
| 12047 | Options to select by index. Optional. |
| 12048 | label : Union[Sequence[str], str, None] |
| 12049 | Options to select by label. If the `<select>` has the `multiple` attribute, all given options are selected, |
| 12050 | otherwise only the first option matching one of the passed options is selected. Optional. |
| 12051 | element : Union[ElementHandle, Sequence[ElementHandle], None] |
| 12052 | Option elements to select. Optional. |
| 12053 | timeout : Union[float, None] |
| 12054 | Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can |
| 12055 | be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. |
no test coverage detected