pub struct LocatorAssertions<'a> { /* private fields */ }Expand description
Assertions for locators (elements).
Implementations§
Source§impl<'a> LocatorAssertions<'a>
impl<'a> LocatorAssertions<'a>
Sourcepub fn new(locator: &'a Locator<'a>) -> Self
pub fn new(locator: &'a Locator<'a>) -> Self
Create a new LocatorAssertions for the given locator.
Sourcepub fn negated(self) -> Self
pub fn negated(self) -> Self
Negate the assertion.
This is an alias for the not method to avoid conflict with std::ops::Not.
Sourcepub fn not(self) -> Self
pub fn not(self) -> Self
Negate the assertion.
Note: This method name shadows the Not trait’s method. Use negated() if
you need to avoid this conflict.
Sourcepub async fn to_be_visible(&self) -> Result<(), AssertionError>
pub async fn to_be_visible(&self) -> Result<(), AssertionError>
Assert that the element is visible.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Assert that the element is hidden.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_text(&self, expected: &str) -> Result<(), AssertionError>
pub async fn to_have_text(&self, expected: &str) -> Result<(), AssertionError>
Assert that the element has the exact text content.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_contain_text(
&self,
expected: &str,
) -> Result<(), AssertionError>
pub async fn to_contain_text( &self, expected: &str, ) -> Result<(), AssertionError>
Assert that the element contains the specified text.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_attribute(
&self,
name: &str,
value: &str,
) -> Result<(), AssertionError>
pub async fn to_have_attribute( &self, name: &str, value: &str, ) -> Result<(), AssertionError>
Assert that the element has the specified attribute value.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_class(
&self,
class_name: &str,
) -> Result<(), AssertionError>
pub async fn to_have_class( &self, class_name: &str, ) -> Result<(), AssertionError>
Assert that the element has the specified class.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_be_enabled(&self) -> Result<(), AssertionError>
pub async fn to_be_enabled(&self) -> Result<(), AssertionError>
Assert that the element is enabled.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_be_disabled(&self) -> Result<(), AssertionError>
pub async fn to_be_disabled(&self) -> Result<(), AssertionError>
Assert that the element is disabled.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_be_checked(&self) -> Result<(), AssertionError>
pub async fn to_be_checked(&self) -> Result<(), AssertionError>
Assert that the element is checked (for checkboxes/radios).
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_value(&self, expected: &str) -> Result<(), AssertionError>
pub async fn to_have_value(&self, expected: &str) -> Result<(), AssertionError>
Assert that the element has the specified value (for input/textarea/select).
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_values(
&self,
expected: &[&str],
) -> Result<(), AssertionError>
pub async fn to_have_values( &self, expected: &[&str], ) -> Result<(), AssertionError>
Assert that a multi-select element has the specified values selected.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_id(&self, expected: &str) -> Result<(), AssertionError>
pub async fn to_have_id(&self, expected: &str) -> Result<(), AssertionError>
Assert that the element has the specified id.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_have_count(&self, expected: usize) -> Result<(), AssertionError>
pub async fn to_have_count(&self, expected: usize) -> Result<(), AssertionError>
Assert that the element has the specified count.
§Errors
Returns an error if the assertion fails or the elements cannot be counted.
Sourcepub async fn to_have_count_greater_than(
&self,
n: usize,
) -> Result<(), AssertionError>
pub async fn to_have_count_greater_than( &self, n: usize, ) -> Result<(), AssertionError>
Assert that the element count is greater than a value.
§Errors
Returns an error if the assertion fails or the elements cannot be counted.
Sourcepub async fn to_have_count_less_than(
&self,
n: usize,
) -> Result<(), AssertionError>
pub async fn to_have_count_less_than( &self, n: usize, ) -> Result<(), AssertionError>
Assert that the element count is less than a value.
§Errors
Returns an error if the assertion fails or the elements cannot be counted.
Sourcepub async fn to_have_count_at_least(
&self,
n: usize,
) -> Result<(), AssertionError>
pub async fn to_have_count_at_least( &self, n: usize, ) -> Result<(), AssertionError>
Assert that the element count is at least a value (greater than or equal).
§Errors
Returns an error if the assertion fails or the elements cannot be counted.
Sourcepub async fn to_have_count_at_most(
&self,
n: usize,
) -> Result<(), AssertionError>
pub async fn to_have_count_at_most( &self, n: usize, ) -> Result<(), AssertionError>
Assert that the element count is at most a value (less than or equal).
§Errors
Returns an error if the assertion fails or the elements cannot be counted.
Sourcepub async fn to_have_texts(
&self,
expected: &[&str],
) -> Result<(), AssertionError>
pub async fn to_have_texts( &self, expected: &[&str], ) -> Result<(), AssertionError>
Assert that all elements have the specified texts (in order).
§Errors
Returns an error if the assertion fails or the elements cannot be queried.
Sourcepub async fn to_match_aria_snapshot(
&self,
expected: &AriaSnapshot,
) -> Result<(), AssertionError>
pub async fn to_match_aria_snapshot( &self, expected: &AriaSnapshot, ) -> Result<(), AssertionError>
Assert that the element’s ARIA snapshot matches the expected structure.
This method compares the accessibility tree of the element against an expected
snapshot. The expected snapshot can contain regex patterns in name fields
when enclosed in /pattern/ syntax.
§Errors
Returns an error if the assertion fails or the element cannot be queried.
Sourcepub async fn to_match_aria_snapshot_yaml(
&self,
expected_yaml: &str,
) -> Result<(), AssertionError>
pub async fn to_match_aria_snapshot_yaml( &self, expected_yaml: &str, ) -> Result<(), AssertionError>
Assert that the element’s ARIA snapshot matches the expected YAML string.
This is a convenience method that parses the YAML string and delegates to
to_match_aria_snapshot.
§Errors
Returns an error if the YAML parsing fails, the assertion fails, or the element cannot be queried.
Sourcepub async fn to_contain_texts(
&self,
expected: &[&str],
) -> Result<(), AssertionError>
pub async fn to_contain_texts( &self, expected: &[&str], ) -> Result<(), AssertionError>
Assert that all elements contain the specified texts (in order).
§Errors
Returns an error if the assertion fails or the elements cannot be queried.
Sourcepub async fn to_have_classes(
&self,
expected_classes: &[&str],
) -> Result<(), AssertionError>
pub async fn to_have_classes( &self, expected_classes: &[&str], ) -> Result<(), AssertionError>
Assert that the element has all specified classes.
Unlike to_have_class() which checks for a single class, this method
verifies that the element has ALL specified classes.
§Errors
Returns an error if the assertion fails or the element cannot be queried.