pub struct SelectElement { /* private fields */ }
Expand description

Convenience wrapper for <select> elements.

Implementations§

source§

impl SelectElement

source

pub async fn new(element: &WebElement) -> WebDriverResult<SelectElement>

Instantiate a new SelectElement struct. The specified element must be a <select> element.

source

pub async fn options(&self) -> WebDriverResult<Vec<WebElement>>

Return a vec of all options belonging to this select tag.

source

pub async fn all_selected_options(&self) -> WebDriverResult<Vec<WebElement>>

Return a vec of all selected options belonging to this select tag.

source

pub async fn first_selected_option(&self) -> WebDriverResult<WebElement>

Return the first selected option in this select tag.

source

pub async fn select_all(&self) -> WebDriverResult<()>

Select all options for this select tag.

source

pub async fn select_by_value(&self, value: &str) -> WebDriverResult<()>

Select options matching the specified value.

source

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.

source

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().

source

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.

source

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.

source

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.

source

pub async fn deselect_all(&self) -> WebDriverResult<()>

Deselect all options for this select tag.

source

pub async fn deselect_by_value(&self, value: &str) -> WebDriverResult<()>

Deselect options matching the specified value.

source

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.

source

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().

source

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.

source

pub async fn deselect_by_exact_text(&self, text: &str) -> WebDriverResult<()>

Deselect all options with visible text exactly matching the specified text.

source

pub async fn deselect_by_partial_text(&self, text: &str) -> WebDriverResult<()>

Deselect all options with visible text partially matching the specified text.

Trait Implementations§

source§

impl Debug for SelectElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more