selenium.webdriver.support.select¶
Classes
|
Constructor. |
- class selenium.webdriver.support.select.Select(webelement: WebElement)[source]¶
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)
- Raises:
UnexpectedTagNameException: If the element is not a SELECT tag
- property options: list[WebElement]¶
Returns a list of all options belonging to this select tag.
- property all_selected_options: list[WebElement]¶
Return a list of all selected options belonging to this select tag.
- property first_selected_option: WebElement¶
Return the first selected option or the currently selected option.
- select_by_value(value: str) None[source]¶
Select all options that have a value matching the argument.
- Example:
When given “foo” this would select an option like:
<option value=”foo”>Bar</option>
- Args:
value: The value to match against
- Raises:
NoSuchElementException: If there is no option with specified value in SELECT
- select_by_index(index: int) None[source]¶
Select the option at the given index by examining the “index” attribute.
- Args:
index: The option at this index will be selected
- Raises:
NoSuchElementException: If there is no option with specified index in SELECT
- select_by_visible_text(text: str) None[source]¶
Select all options that display text matching the argument.
- Example:
When given “Bar” this would select an option like:
<option value=”foo”>Bar</option>
- Args:
text: The visible text to match against
- Raises:
NoSuchElementException: If there is no option with specified text in SELECT
- deselect_all() None[source]¶
Clear all selected entries.
This is only valid when the SELECT supports multiple selections. throws NotImplementedError If the SELECT does not support multiple selections
- deselect_by_value(value: str) None[source]¶
Deselect all options that have a value matching the argument.
- Example:
When given “foo” this would deselect an option like:
<option value=”foo”>Bar</option>
- Args:
value: The value to match against
- Raises:
NoSuchElementException: If there is no option with specified value in SELECT