Constructor. A check is made that the given element is a SELECT tag. Args: webelement: SELECT element to wrap Example: from selenium.webdriver.support.ui import Select Select(driver.find_element(By.TAG_NAME, "select")).select_by_index(2)
(self, webelement: WebElement)
| 23 | |
| 24 | class Select: |
| 25 | def __init__(self, webelement: WebElement) -> None: |
| 26 | """Constructor. A check is made that the given element is a SELECT tag. |
| 27 | |
| 28 | Args: |
| 29 | webelement: SELECT element to wrap |
| 30 | |
| 31 | Example: |
| 32 | from selenium.webdriver.support.ui import Select |
| 33 | Select(driver.find_element(By.TAG_NAME, "select")).select_by_index(2) |
| 34 | |
| 35 | Raises: |
| 36 | UnexpectedTagNameException: If the element is not a SELECT tag |
| 37 | """ |
| 38 | if webelement.tag_name.lower() != "select": |
| 39 | raise UnexpectedTagNameException(f"Select only works on <select> elements, not on {webelement.tag_name}") |
| 40 | self._el = webelement |
| 41 | multi = self._el.get_dom_attribute("multiple") |
| 42 | self.is_multiple = multi and multi != "false" |
| 43 | |
| 44 | @property |
| 45 | def options(self) -> list[WebElement]: |
nothing calls this directly
no test coverage detected