Expectation

Struct Expectation 

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

Expectation wraps a locator and provides assertion methods with auto-retry.

Implementations§

Source§

impl Expectation

Source

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

Sets a custom timeout for this assertion.

Source

pub fn with_poll_interval(self, interval: Duration) -> Self

Sets a custom poll interval for this assertion.

Default is 100ms.

Source

pub fn not(self) -> Self

Negates the assertion.

Note: We intentionally use .not() method instead of implementing std::ops::Not to match Playwright’s API across all language bindings (JS/Python/Java/.NET).

Source

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

Asserts that the element is visible.

This assertion will retry until the element becomes visible or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-visible

Source

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

Asserts that the element is hidden (not visible).

This assertion will retry until the element becomes hidden or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-hidden

Source

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

Asserts that the element has the specified text content (exact match).

This assertion will retry until the element has the exact text or timeout. Text is trimmed before comparison.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-have-text

Source

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

Asserts that the element’s text matches the specified regex pattern.

This assertion will retry until the element’s text matches the pattern or timeout.

Source

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

Asserts that the element contains the specified text (substring match).

This assertion will retry until the element contains the text or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-contain-text

Source

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

Asserts that the element’s text contains a substring matching the regex pattern.

This assertion will retry until the element contains the pattern or timeout.

Source

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

Asserts that the input element has the specified value.

This assertion will retry until the input has the exact value or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-have-value

Source

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

Asserts that the input element’s value matches the specified regex pattern.

This assertion will retry until the input value matches the pattern or timeout.

Source

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

Asserts that the element is enabled.

This assertion will retry until the element is enabled or timeout. An element is enabled if it does not have the “disabled” attribute.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-enabled

Source

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

Asserts that the element is disabled.

This assertion will retry until the element is disabled or timeout. An element is disabled if it has the “disabled” attribute.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-disabled

Source

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

Asserts that the checkbox or radio button is checked.

This assertion will retry until the element is checked or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-checked

Source

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

Asserts that the checkbox or radio button is unchecked.

This assertion will retry until the element is unchecked or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-checked

Source

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

Asserts that the element is editable.

This assertion will retry until the element is editable or timeout. An element is editable if it is enabled and does not have the “readonly” attribute.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-editable

Source

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

Asserts that the element is focused (currently has focus).

This assertion will retry until the element becomes focused or timeout.

See: https://playwright.dev/docs/test-assertions#locator-assertions-to-be-focused

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>,

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<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