Skip to main content

LocatorAssertions

Struct LocatorAssertions 

Source
pub struct LocatorAssertions { /* private fields */ }
Expand description

Assertions over a Locator, produced by expect.

Implementations§

Source§

impl LocatorAssertions

Source

pub fn new(locator: Locator) -> Self

Wrap a locator with the default 5s timeout, non-negated.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Builder: override the assertion timeout.

Source

pub fn set_timeout(&mut self, timeout: Duration) -> &mut Self

Override the assertion timeout in place.

Source

pub fn not(&self) -> Self

Return a negated clone: succeeding when the base condition is false.

Source

pub async fn to_be_visible(&self) -> Result<()>

Source

pub async fn to_be_hidden(&self) -> Result<()>

Source

pub async fn to_be_enabled(&self) -> Result<()>

Source

pub async fn to_be_disabled(&self) -> Result<()>

Source

pub async fn to_be_editable(&self) -> Result<()>

Source

pub async fn to_be_checked(&self) -> Result<()>

Source

pub async fn to_be_unchecked(&self) -> Result<()>

Source

pub async fn to_have_text(&self, expected: &str) -> Result<()>

Assert the element’s trimmed textContent equals expected.

Source

pub async fn to_contain_text(&self, expected: &str) -> Result<()>

Assert the element’s trimmed textContent contains expected.

Source

pub async fn to_have_inner_text(&self, expected: &str) -> Result<()>

Assert the element’s innerText equals expected.

Source

pub async fn to_have_text_regex(&self, pattern: &str) -> Result<()>

Assert the element’s trimmed textContent matches the regex pattern.

Source

pub async fn to_contain_text_regex(&self, pattern: &str) -> Result<()>

Assert the element’s textContent matches the regex pattern (no trim).

Source

pub async fn to_have_inner_text_regex(&self, pattern: &str) -> Result<()>

Assert the element’s innerText matches the regex pattern.

Source

pub async fn to_have_count(&self, expected: usize) -> Result<()>

Assert the number of matching elements equals expected.

Source

pub async fn to_have_attribute(&self, name: &str, value: &str) -> Result<()>

Assert the element has attribute name equal to value.

Source

pub async fn to_have_value(&self, expected: &str) -> Result<()>

Assert the element’s input value equals expected.

Source

pub async fn to_have_value_regex(&self, pattern: &str) -> Result<()>

Assert the element’s input value matches the regex pattern.

Source

pub async fn to_have_attribute_regex( &self, name: &str, pattern: &str, ) -> Result<()>

Assert the element’s class attribute matches the regex pattern.

Source

pub async fn to_have_css(&self, name: &str, value: &str) -> Result<()>

Assert the element’s computed CSS property name equals value.

Reads the value via getComputedStyle(el).getPropertyValue(name) and compares for exact equality.

Source

pub async fn to_have_css_regex(&self, name: &str, pattern: &str) -> Result<()>

Assert the element’s computed CSS property name matches the regex pattern.

Source

pub async fn to_have_class(&self, expected: &str) -> Result<()>

Assert the element’s class attribute equals expected.

Source

pub async fn to_have_class_regex(&self, pattern: &str) -> Result<()>

Assert the element’s class attribute matches the regex pattern.

Source

pub async fn to_be_focused(&self) -> Result<()>

Assert the element is the current document.activeElement.

Source

pub async fn to_match_aria_snapshot(&self, expected: &str) -> Result<()>

Assert the element’s aria snapshot equals expected.

Simplified variant: compares the trimmed snapshot string against the trimmed expected for exact equality. This is not Playwright’s structured accessibility-tree diff (it does no node normalization or whitespace folding beyond trim()), so mismatches in indentation or ordering will fail even when the trees are semantically equivalent.

Source

pub async fn to_have_screenshot( &self, name: &str, options: Option<ScreenshotAssertOptions>, ) -> Result<()>

Assert the element’s screenshot matches a baseline PNG file name.

A .png suffix is appended to name if absent. If the baseline does not yet exist, the first run writes it (establishing the baseline) and succeeds.

Comparison mode depends on the screenshot-diff cargo feature:

  • Feature OFF (default): exact byte-level comparison of the captured PNG against the baseline. The rendered bytes must be identical. The options argument is accepted but ignored.
  • Feature ON (screenshot-diff): pixel-level tolerance comparison via the image crate. Both PNGs are decoded to RGBA and compared pixel-by-pixel; a mismatch is reported only when the number of differing pixels exceeds the tolerance in ScreenshotAssertOptions (max_diff_pixels / threshold). Disable the feature to drop the image dependency entirely.

On mismatch the actual bytes are always dumped to {name}-actual.png for inspection, and the error message carries diff statistics.

Because this captures a single frame rather than polling a condition, it bypasses [wait_for] and runs to completion immediately.

Source

pub async fn to_be_empty(&self) -> Result<()>

Assert the element is empty: an empty input value, or zero matching elements.

Trait Implementations§

Source§

impl Clone for LocatorAssertions

Source§

fn clone(&self) -> LocatorAssertions

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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>,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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