Skip to main content

ElementResolver

Struct ElementResolver 

Source
pub struct ElementResolver<T> { /* private fields */ }
Expand description

Element resolver that can resolve a particular element or list of elements on demand.

Once resolved, the result will be cached for later retrieval until manually invalidated.

Implementations§

Source§

impl<T> ElementResolver<T>
where T: Clone + 'static,

Source

pub fn new_custom( base_element: WebElement, query_fn: impl ElementQueryFn<T> + 'static, ) -> ElementResolver<T>

Create a new resolver using a custom resolver function.

Source

pub async fn resolve(&self) -> Result<T, WebDriverError>

Return the cached element(s) if any, otherwise run the query and return the result.

Source

pub fn invalidate(&self)

Invalidate any cached element(s).

Source

pub async fn resolve_force(&self) -> Result<T, WebDriverError>
where T: Clone,

Run the query, ignoring any cached element(s).

Source§

impl<T> ElementResolver<T>
where T: Resolve + Clone + 'static,

Source

pub async fn validate(&self) -> Result<Option<T>, WebDriverError>

Validate that the cached component is present, and if so, return it.

Source

pub async fn resolve_present(&self) -> Result<T, WebDriverError>

Validate the element or component and repeat the query if it is not present, returning the result.

If the component is already present, the cached component will be returned without performing an additional query.

Source§

impl ElementResolver<WebElement>

Source

pub async fn click(&self) -> Result<(), WebDriverError>

Resolve a present element and call WebElement::click() on it.

This validates the cached element and re-runs the resolver first if it is stale.

Source

pub async fn click_when_ready(&self) -> Result<(), WebDriverError>

Resolve a present element and call WebElement::click_when_ready() on it.

The click can still fail if, for example, the element becomes stale or another element intercepts the click after the readiness check. This does not retry the click or wait for an application outcome.

Source

pub async fn clear(&self) -> Result<(), WebDriverError>

Resolve a present element and call WebElement::clear() on it.

Source

pub async fn send_keys( &self, key: impl Into<TypingData>, ) -> Result<(), WebDriverError>

Resolve a present element and forward the specified TypingData to WebElement::send_keys().

Source

pub async fn text(&self) -> Result<String, WebDriverError>

Resolve a present element and return WebElement::text().

Source

pub async fn value(&self) -> Result<Option<String>, WebDriverError>

Resolve a present element and return its optional value property from WebElement::value().

Source

pub fn new_single( base_element: WebElement, by: By, ) -> ElementResolver<WebElement>

Create a new element resolver that must return a single element.

Source

pub fn new_single_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<WebElement>

Create a new element resolver that must return a single element, with extra options.

Source

pub fn new_first( base_element: WebElement, by: By, ) -> ElementResolver<WebElement>

Create a new element resolver that returns the first element.

Source

pub fn new_first_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<WebElement>

Create a new element resolver that returns the first element, with extra options.

Source§

impl ElementResolver<Vec<WebElement>>

Source

pub fn new_allow_empty( base_element: WebElement, by: By, ) -> ElementResolver<Vec<WebElement>>

Create a new element resolver that returns all elements, if any.

If no elements were found, this will resolve to an empty Vec.

Source

pub fn new_allow_empty_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<Vec<WebElement>>

Create a new element resolver that returns all elements (if any), with extra options.

Source

pub fn new_not_empty( base_element: WebElement, by: By, ) -> ElementResolver<Vec<WebElement>>

Create a new element resolver that returns at least one element.

If no elements were found, a NoSuchElement error will be returned by the resolver’s resolve() method.

Source

pub fn new_not_empty_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<Vec<WebElement>>

Create a new element resolver that returns at least one element, with extra options.

If no elements were found, a NoSuchElement error will be returned by the resolver’s resolve() method.

Source§

impl<T> ElementResolver<T>
where T: Component + Clone + 'static,

Source

pub fn new_single(base_element: WebElement, by: By) -> ElementResolver<T>

Create a new element resolver that must return a single component.

Source

pub fn new_single_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<T>

Create a new element resolver that must return a single component, with extra options.

Source

pub fn new_first(base_element: WebElement, by: By) -> ElementResolver<T>

Create a new element resolver that returns the first component.

Source

pub fn new_first_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<T>

Create a new element resolver that returns the first component, with extra options.

Source§

impl<T> ElementResolver<Vec<T>>
where T: Component + Clone + 'static,

Source

pub fn new_allow_empty( base_element: WebElement, by: By, ) -> ElementResolver<Vec<T>>

Create a new element resolver that returns all components, if any.

If no components were found, this will resolve to an empty Vec.

Source

pub fn new_allow_empty_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<Vec<T>>

Create a new element resolver that returns all components (if any), with extra options.

Source

pub fn new_not_empty( base_element: WebElement, by: By, ) -> ElementResolver<Vec<T>>

Create a new element resolver that returns at least one component.

If no components were found, a NoSuchElement error will be returned by the resolver’s resolve() method.

Source

pub fn new_not_empty_opts( base_element: WebElement, by: By, options: ElementQueryOptions, ) -> ElementResolver<Vec<T>>

Create a new element resolver that returns at least one component, with extra options.

If no components were found, a NoSuchElement error will be returned by the resolver’s resolve() method.

Trait Implementations§

Source§

impl<T> Clone for ElementResolver<T>
where T: Clone,

Source§

fn clone(&self) -> ElementResolver<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for ElementResolver<T>
where T: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ElementResolver<T>

§

impl<T> !UnwindSafe for ElementResolver<T>

§

impl<T> Forget for ElementResolver<T>

§

impl<T> Freeze for ElementResolver<T>
where Arc<dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>>: Freeze, Arc<ArcSwapAny<Arc<OnceCell<T>>>>: Freeze,

§

impl<T> Move for ElementResolver<T>

§

impl<T> Send for ElementResolver<T>
where Arc<dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>>: Send, Arc<ArcSwapAny<Arc<OnceCell<T>>>>: Send,

§

impl<T> Sync for ElementResolver<T>
where Arc<dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>>: Sync, Arc<ArcSwapAny<Arc<OnceCell<T>>>>: Sync,

§

impl<T> Unpin for ElementResolver<T>
where Arc<dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>>: Unpin, Arc<ArcSwapAny<Arc<OnceCell<T>>>>: Unpin,

§

impl<T> UnsafeUnpin for ElementResolver<T>
where Arc<dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>>: UnsafeUnpin, Arc<ArcSwapAny<Arc<OnceCell<T>>>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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