Class Ensure
java.lang.Object
net.serenitybdd.screenplay.playwright.assertions.Ensure
Perform assertions about the state of elements, pages, and URLs using Playwright's
native assertion API with built-in auto-retry.
Sample usage:
actor.attemptsTo(
// Element assertions
Ensure.that("#element").isVisible(),
Ensure.that("#element").hasText("Hello"),
Ensure.that("#element").containsText("ello"),
Ensure.that("#element").hasTextMatching("Hel.*"),
Ensure.that("#element").hasAttribute("class", "active"),
Ensure.that("#element").hasClass("active"),
Ensure.that(".items").hasCount(5),
// URL assertions
Ensure.thatTheCurrentUrl().contains("/dashboard"),
// Page title assertions
Ensure.thatThePageTitle().isEqualTo("Dashboard"),
Ensure.thatThePageTitle().contains("Dashboard")
);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.serenitybdd.screenplay.PerformablecontainsText(String expectedText) Check whether the element contains the specified text.net.serenitybdd.screenplay.PerformablecurrentValue(String expectedValue) Check whether the input element has the expected value.net.serenitybdd.screenplay.PerformablehasAttribute(String name, String value) Check whether the element has an attribute with the expected value.net.serenitybdd.screenplay.PerformablehasAttributeContaining(String name, String substring) Check whether the element has an attribute containing the expected substring.net.serenitybdd.screenplay.PerformableCheck whether the element has the specified CSS class.net.serenitybdd.screenplay.PerformablehasCount(int count) Check that the locator resolves to the expected number of elements.net.serenitybdd.screenplay.PerformablehasCSSValue(String name, String value) Check whether the element has the expected CSS property value.net.serenitybdd.screenplay.PerformableCheck whether the element has the exact text.net.serenitybdd.screenplay.PerformablehasTextMatching(String regex) Check whether the element text matches a regex pattern (as string).net.serenitybdd.screenplay.PerformablehasTextMatching(Pattern pattern) Check whether the element text matches a regex pattern.net.serenitybdd.screenplay.PerformableAlias for currentValue.net.serenitybdd.screenplay.PerformableCheck whether the element is checked (for checkbox/radio).net.serenitybdd.screenplay.PerformableCheck whether the element is disabled.net.serenitybdd.screenplay.PerformableCheck whether the element is editable.net.serenitybdd.screenplay.PerformableisEmpty()Check whether the input element is empty.net.serenitybdd.screenplay.PerformableCheck whether the element is enabled.net.serenitybdd.screenplay.PerformableCheck whether the element has focus.net.serenitybdd.screenplay.PerformableisHidden()Check whether the element is not visible.net.serenitybdd.screenplay.PerformableCheck whether the element is NOT checked.net.serenitybdd.screenplay.PerformableCheck whether the element is not empty.net.serenitybdd.screenplay.PerformableCheck whether the element is visible.static EnsureStart an assertion about an element identified by a selector.static EnsureStart an assertion about a Target element.static net.serenitybdd.screenplay.playwright.assertions.UrlEnsureStart an assertion about the current URL.static net.serenitybdd.screenplay.playwright.assertions.PageTitleEnsureStart an assertion about the page title.withTimeout(Double timeout) Set a custom timeout for this assertion.
-
Constructor Details
-
Ensure
-
-
Method Details
-
that
Start an assertion about an element identified by a selector. -
that
Start an assertion about a Target element. -
thatTheCurrentUrl
public static net.serenitybdd.screenplay.playwright.assertions.UrlEnsure thatTheCurrentUrl()Start an assertion about the current URL. -
thatThePageTitle
public static net.serenitybdd.screenplay.playwright.assertions.PageTitleEnsure thatThePageTitle()Start an assertion about the page title. -
withTimeout
Set a custom timeout for this assertion. -
isVisible
public net.serenitybdd.screenplay.Performable isVisible()Check whether the element is visible. -
isHidden
public net.serenitybdd.screenplay.Performable isHidden()Check whether the element is not visible. -
isChecked
public net.serenitybdd.screenplay.Performable isChecked()Check whether the element is checked (for checkbox/radio). -
isNotChecked
public net.serenitybdd.screenplay.Performable isNotChecked()Check whether the element is NOT checked. -
isEnabled
public net.serenitybdd.screenplay.Performable isEnabled()Check whether the element is enabled. -
isDisabled
public net.serenitybdd.screenplay.Performable isDisabled()Check whether the element is disabled. -
isEditable
public net.serenitybdd.screenplay.Performable isEditable()Check whether the element is editable. -
isFocused
public net.serenitybdd.screenplay.Performable isFocused()Check whether the element has focus. -
isEmpty
public net.serenitybdd.screenplay.Performable isEmpty()Check whether the input element is empty. -
isNotEmpty
public net.serenitybdd.screenplay.Performable isNotEmpty()Check whether the element is not empty. -
hasText
Check whether the element has the exact text. -
containsText
Check whether the element contains the specified text. -
hasTextMatching
Check whether the element text matches a regex pattern (as string). -
hasTextMatching
Check whether the element text matches a regex pattern. -
currentValue
Check whether the input element has the expected value. -
hasValue
Alias for currentValue. -
hasAttribute
Check whether the element has an attribute with the expected value. -
hasAttributeContaining
Check whether the element has an attribute containing the expected substring. -
hasClass
Check whether the element has the specified CSS class. -
hasCount
public net.serenitybdd.screenplay.Performable hasCount(int count) Check that the locator resolves to the expected number of elements. -
hasCSSValue
Check whether the element has the expected CSS property value.
-