pub struct SelectElement { /* private fields */ }
Expand description
Convenience wrapper for <select>
elements.
Implementations§
Source§impl SelectElement
impl SelectElement
Sourcepub async fn new(element: &WebElement) -> WebDriverResult<SelectElement>
pub async fn new(element: &WebElement) -> WebDriverResult<SelectElement>
Instantiate a new SelectElement struct. The specified element must be a <select>
element.
Sourcepub async fn options(&self) -> WebDriverResult<Vec<WebElement>>
pub async fn options(&self) -> WebDriverResult<Vec<WebElement>>
Return a vec of all options belonging to this select tag.
Sourcepub async fn all_selected_options(&self) -> WebDriverResult<Vec<WebElement>>
pub async fn all_selected_options(&self) -> WebDriverResult<Vec<WebElement>>
Return a vec of all selected options belonging to this select tag.
Sourcepub async fn first_selected_option(&self) -> WebDriverResult<WebElement>
pub async fn first_selected_option(&self) -> WebDriverResult<WebElement>
Return the first selected option in this select tag.
Sourcepub async fn select_all(&self) -> WebDriverResult<()>
pub async fn select_all(&self) -> WebDriverResult<()>
Select all options for this select tag.
Sourcepub async fn select_by_value(&self, value: &str) -> WebDriverResult<()>
pub async fn select_by_value(&self, value: &str) -> WebDriverResult<()>
Select options matching the specified value.
Sourcepub async fn select_by_index(&self, index: u32) -> WebDriverResult<()>
pub async fn select_by_index(&self, index: u32) -> WebDriverResult<()>
Select the option matching the specified index. This is done by examining the “index” attribute of an element and not merely by counting.
Sourcepub async fn select_by_visible_text(&self, text: &str) -> WebDriverResult<()>
pub async fn select_by_visible_text(&self, text: &str) -> WebDriverResult<()>
Select options with visible text matching the specified text. That is, when given “Bar” this would select an option like:
<option value="foo">Bar</option>
This will attempt to select by exact match, but if no option is found it will also
attempt to select based on the longest contiguous word in the text.
See also select_by_exact_text()
and select_by_partial_text()
.
Sourcepub async fn select_by_xpath_condition(
&self,
condition: &str,
) -> WebDriverResult<()>
pub async fn select_by_xpath_condition( &self, condition: &str, ) -> WebDriverResult<()>
Select options matching the specified XPath condition.
E.g. The specified condition replaces {}
in this XPath: .//option[{}]
The following example would match .//option[starts-with(text(), 'pre')]
:
select_by_xpath_condition("starts-with(text(), 'pre')").await?;
For multi-select, all options matching the condition will be selected. For single-select, only the first matching option will be selected.
Sourcepub async fn select_by_exact_text(&self, text: &str) -> WebDriverResult<()>
pub async fn select_by_exact_text(&self, text: &str) -> WebDriverResult<()>
Select options with visible text exactly matching the specified text. For multi-select, all options whose text exactly matches will be selected. For single-select, only the first exact match will be selected.
Sourcepub async fn select_by_partial_text(&self, text: &str) -> WebDriverResult<()>
pub async fn select_by_partial_text(&self, text: &str) -> WebDriverResult<()>
Select options with visible text partially matching the specified text. For multi-select, all options whose text contains the specified substring will be selected. For single-select, only the first option containing the substring will be selected.
Sourcepub async fn deselect_all(&self) -> WebDriverResult<()>
pub async fn deselect_all(&self) -> WebDriverResult<()>
Deselect all options for this select tag.
Sourcepub async fn deselect_by_value(&self, value: &str) -> WebDriverResult<()>
pub async fn deselect_by_value(&self, value: &str) -> WebDriverResult<()>
Deselect options matching the specified value.
Sourcepub async fn deselect_by_index(&self, index: u32) -> WebDriverResult<()>
pub async fn deselect_by_index(&self, index: u32) -> WebDriverResult<()>
Deselect the option matching the specified index. This is done by examining the “index” attribute of an element and not merely by counting.
Sourcepub async fn deselect_by_visible_text(&self, text: &str) -> WebDriverResult<()>
pub async fn deselect_by_visible_text(&self, text: &str) -> WebDriverResult<()>
Deselect options with visible text matching the specified text. That is, when given “Bar” this would deselect an option like:
<option value="foo">Bar</option>
See also deselect_by_exact_text()
and deselect_by_partial_text()
.
Sourcepub async fn deselect_by_xpath_condition(
&self,
condition: &str,
) -> WebDriverResult<()>
pub async fn deselect_by_xpath_condition( &self, condition: &str, ) -> WebDriverResult<()>
Deselect options matching the specified XPath condition.
E.g. The specified condition replaces {}
in this XPath: .//option[{}]
The following example would match .//option[starts-with(text(), 'pre')]
:
deselect_by_xpath_condition("starts-with(text(), 'pre')").await?;
For multi-select, all options matching the condition will be deselected. For single-select, only the first matching option will be deselected.
Sourcepub async fn deselect_by_exact_text(&self, text: &str) -> WebDriverResult<()>
pub async fn deselect_by_exact_text(&self, text: &str) -> WebDriverResult<()>
Deselect all options with visible text exactly matching the specified text.
Sourcepub async fn deselect_by_partial_text(&self, text: &str) -> WebDriverResult<()>
pub async fn deselect_by_partial_text(&self, text: &str) -> WebDriverResult<()>
Deselect all options with visible text partially matching the specified text.