MCPcopy Index your code
hub / github.com/microsoft/playwright-python / select_option

Method select_option

playwright/async_api/_generated.py:2419–2493  ·  view source on GitHub ↗

ElementHandle.select_option This method 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 element is not a ` ` element,

(
        self,
        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,
        force: typing.Optional[bool] = None,
        no_wait_after: typing.Optional[bool] = None,
    )

Source from the content-addressed store, hash-verified

2417 )
2418
2419 async def select_option(
2420 self,
2421 value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
2422 *,
2423 index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None,
2424 label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
2425 element: typing.Optional[
2426 typing.Union["ElementHandle", typing.Sequence["ElementHandle"]]
2427 ] = None,
2428 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
2429 force: typing.Optional[bool] = None,
2430 no_wait_after: typing.Optional[bool] = None,
2431 ) -> typing.List[str]:
2432 """ElementHandle.select_option
2433
2434 This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in
2435 the `<select>` element and selects these options.
2436
2437 If the target element is not a `<select>` element, this method throws an error. However, if the element is inside
2438 the `<label>` element that has an associated
2439 [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used
2440 instead.
2441
2442 Returns the array of option values that have been successfully selected.
2443
2444 Triggers a `change` and `input` event once all the provided options have been selected.
2445
2446 **Usage**
2447
2448 ```py
2449 # Single selection matching the value or label
2450 await handle.select_option(\"blue\")
2451 # single selection matching the label
2452 await handle.select_option(label=\"blue\")
2453 # multiple selection
2454 await handle.select_option(value=[\"red\", \"green\", \"blue\"])
2455 ```
2456
2457 Parameters
2458 ----------
2459 value : Union[Sequence[str], str, None]
2460 Options to select by value. If the `<select>` has the `multiple` attribute, all given options are selected,
2461 otherwise only the first option matching one of the passed options is selected. Optional.
2462 index : Union[Sequence[int], int, None]
2463 Options to select by index. Optional.
2464 label : Union[Sequence[str], str, None]
2465 Options to select by label. If the `<select>` has the `multiple` attribute, all given options are selected,
2466 otherwise only the first option matching one of the passed options is selected. Optional.
2467 element : Union[ElementHandle, Sequence[ElementHandle], None]
2468 Option elements to select. Optional.
2469 timeout : Union[float, None]
2470 Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can
2471 be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
2472 force : Union[bool, None]
2473 Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
2474 no_wait_after : Union[bool, None]
2475 This option has no effect.
2476 Deprecated: This option has no effect.

Callers

nothing calls this directly

Calls 4

to_millisecondsFunction · 0.90
from_maybe_implMethod · 0.80
to_implMethod · 0.80
select_optionMethod · 0.45

Tested by

no test coverage detected