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,
impl<T> ElementResolver<T>where
T: Clone + 'static,
Sourcepub fn new_custom(
base_element: WebElement,
query_fn: impl ElementQueryFn<T> + 'static,
) -> ElementResolver<T>
pub fn new_custom( base_element: WebElement, query_fn: impl ElementQueryFn<T> + 'static, ) -> ElementResolver<T>
Create a new resolver using a custom resolver function.
Sourcepub async fn resolve(&self) -> Result<T, WebDriverError>
pub async fn resolve(&self) -> Result<T, WebDriverError>
Return the cached element(s) if any, otherwise run the query and return the result.
Sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Invalidate any cached element(s).
Sourcepub async fn resolve_force(&self) -> Result<T, WebDriverError>where
T: Clone,
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>
impl<T> ElementResolver<T>
Sourcepub async fn validate(&self) -> Result<Option<T>, WebDriverError>
pub async fn validate(&self) -> Result<Option<T>, WebDriverError>
Validate that the cached component is present, and if so, return it.
Sourcepub async fn resolve_present(&self) -> Result<T, WebDriverError>
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>
impl ElementResolver<WebElement>
Sourcepub async fn click(&self) -> Result<(), WebDriverError>
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.
Sourcepub async fn click_when_ready(&self) -> Result<(), WebDriverError>
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.
Sourcepub async fn clear(&self) -> Result<(), WebDriverError>
pub async fn clear(&self) -> Result<(), WebDriverError>
Resolve a present element and call WebElement::clear() on it.
Sourcepub async fn send_keys(
&self,
key: impl Into<TypingData>,
) -> Result<(), WebDriverError>
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().
Sourcepub async fn text(&self) -> Result<String, WebDriverError>
pub async fn text(&self) -> Result<String, WebDriverError>
Resolve a present element and return WebElement::text().
Sourcepub async fn value(&self) -> Result<Option<String>, WebDriverError>
pub async fn value(&self) -> Result<Option<String>, WebDriverError>
Resolve a present element and return its optional value property from
WebElement::value().
Sourcepub fn new_single(
base_element: WebElement,
by: By,
) -> ElementResolver<WebElement>
pub fn new_single( base_element: WebElement, by: By, ) -> ElementResolver<WebElement>
Create a new element resolver that must return a single element.
Sourcepub fn new_single_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<WebElement>
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.
Sourcepub fn new_first(
base_element: WebElement,
by: By,
) -> ElementResolver<WebElement>
pub fn new_first( base_element: WebElement, by: By, ) -> ElementResolver<WebElement>
Create a new element resolver that returns the first element.
Sourcepub fn new_first_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<WebElement>
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>>
impl ElementResolver<Vec<WebElement>>
Sourcepub fn new_allow_empty(
base_element: WebElement,
by: By,
) -> ElementResolver<Vec<WebElement>>
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.
Sourcepub fn new_allow_empty_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<Vec<WebElement>>
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.
Sourcepub fn new_not_empty(
base_element: WebElement,
by: By,
) -> ElementResolver<Vec<WebElement>>
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.
Sourcepub fn new_not_empty_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<Vec<WebElement>>
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>
impl<T> ElementResolver<T>
Sourcepub fn new_single(base_element: WebElement, by: By) -> ElementResolver<T>
pub fn new_single(base_element: WebElement, by: By) -> ElementResolver<T>
Create a new element resolver that must return a single component.
Sourcepub fn new_single_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<T>
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.
Sourcepub fn new_first(base_element: WebElement, by: By) -> ElementResolver<T>
pub fn new_first(base_element: WebElement, by: By) -> ElementResolver<T>
Create a new element resolver that returns the first component.
Sourcepub fn new_first_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<T>
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>>
impl<T> ElementResolver<Vec<T>>
Sourcepub fn new_allow_empty(
base_element: WebElement,
by: By,
) -> ElementResolver<Vec<T>>
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.
Sourcepub fn new_allow_empty_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<Vec<T>>
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.
Sourcepub fn new_not_empty(
base_element: WebElement,
by: By,
) -> ElementResolver<Vec<T>>
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.
Sourcepub fn new_not_empty_opts(
base_element: WebElement,
by: By,
options: ElementQueryOptions,
) -> ElementResolver<Vec<T>>
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,
impl<T> Clone for ElementResolver<T>where
T: Clone,
Source§fn clone(&self) -> ElementResolver<T>
fn clone(&self) -> ElementResolver<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more