pub struct Expectation { /* private fields */ }Expand description
Expectation wraps a locator and provides assertion methods with auto-retry.
Implementations§
Source§impl Expectation
impl Expectation
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets a custom timeout for this assertion.
Sourcepub fn with_poll_interval(self, interval: Duration) -> Self
pub fn with_poll_interval(self, interval: Duration) -> Self
Sets a custom poll interval for this assertion.
Default is 100ms.
Sourcepub fn not(self) -> Self
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).
Sourcepub async fn to_be_visible(self) -> Result<()>
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
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
Sourcepub async fn to_have_text(self, expected: &str) -> Result<()>
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
Sourcepub async fn to_have_text_regex(self, pattern: &str) -> Result<()>
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.
Sourcepub async fn to_contain_text(self, expected: &str) -> Result<()>
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
Sourcepub async fn to_contain_text_regex(self, pattern: &str) -> Result<()>
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.
Sourcepub async fn to_have_value(self, expected: &str) -> Result<()>
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
Sourcepub async fn to_have_value_regex(self, pattern: &str) -> Result<()>
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.
Sourcepub async fn to_be_enabled(self) -> Result<()>
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
Sourcepub async fn to_be_disabled(self) -> Result<()>
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
Sourcepub async fn to_be_checked(self) -> Result<()>
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
Sourcepub async fn to_be_unchecked(self) -> Result<()>
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
Sourcepub async fn to_be_editable(self) -> Result<()>
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
Sourcepub async fn to_be_focused(self) -> Result<()>
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