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

Method select_option

playwright/async_api/_generated.py:19749–19835  ·  view source on GitHub ↗

Locator.select_option Selects option or options in ` `. **Details** 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 opti

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

Source from the content-addressed store, hash-verified

19747 )
19748
19749 async def select_option(
19750 self,
19751 value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
19752 *,
19753 index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None,
19754 label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
19755 element: typing.Optional[
19756 typing.Union["ElementHandle", typing.Sequence["ElementHandle"]]
19757 ] = None,
19758 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
19759 no_wait_after: typing.Optional[bool] = None,
19760 force: typing.Optional[bool] = None,
19761 ) -> typing.List[str]:
19762 """Locator.select_option
19763
19764 Selects option or options in `<select>`.
19765
19766 **Details**
19767
19768 This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until all specified options are present in
19769 the `<select>` element and selects these options.
19770
19771 If the target element is not a `<select>` element, this method throws an error. However, if the element is inside
19772 the `<label>` element that has an associated
19773 [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used
19774 instead.
19775
19776 Returns the array of option values that have been successfully selected.
19777
19778 Triggers a `change` and `input` event once all the provided options have been selected.
19779
19780 **Usage**
19781
19782 ```html
19783 <select multiple>
19784 <option value=\"red\">Red</option>
19785 <option value=\"green\">Green</option>
19786 <option value=\"blue\">Blue</option>
19787 </select>
19788 ```
19789
19790 ```py
19791 # single selection matching the value or label
19792 await element.select_option(\"blue\")
19793 # single selection matching the label
19794 await element.select_option(label=\"blue\")
19795 # multiple selection for blue, red and second option
19796 await element.select_option(value=[\"red\", \"green\", \"blue\"])
19797 ```
19798
19799 Parameters
19800 ----------
19801 value : Union[Sequence[str], str, None]
19802 Options to select by value. If the `<select>` has the `multiple` attribute, all given options are selected,
19803 otherwise only the first option matching one of the passed options is selected. Optional.
19804 index : Union[Sequence[int], int, None]
19805 Options to select by index. Optional.
19806 label : Union[Sequence[str], str, None]

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