Class WaitUntil
java.lang.Object
net.serenitybdd.screenplay.playwright.waits.WaitUntil
Wait for elements or page states using Playwright's native waiting mechanisms.
Playwright has built-in auto-waiting for most operations, but sometimes you need explicit waits for dynamic content. This class provides a fluent API for waiting.
Sample usage:
actor.attemptsTo(
WaitUntil.the("#element").isVisible(),
WaitUntil.the("#loading").isHidden(),
WaitUntil.the("#button").isEnabled(),
WaitUntil.the("#result").containsText("Success"),
WaitUntil.the("#element").isVisible().forNoMoreThan(Duration.ofSeconds(30)),
WaitUntil.thePageIsLoaded(),
WaitUntil.networkIsIdle(),
WaitUntil.theUrl().contains("/dashboard")
);
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.serenitybdd.screenplay.PerformableWait for the page to fully load (including all resources).net.serenitybdd.screenplay.playwright.waits.WaitForTextcontainsText(String text) Wait for element to contain specific text.net.serenitybdd.screenplay.playwright.waits.WaitForExactTextWait for element to have specific text (exact match).net.serenitybdd.screenplay.playwright.waits.WaitForElementStateWait for element to be attached to DOM.net.serenitybdd.screenplay.playwright.waits.WaitForElementStateWait for element to be detached from DOM.net.serenitybdd.screenplay.playwright.waits.WaitForDisabledWait for element to be disabled.net.serenitybdd.screenplay.playwright.waits.WaitForEnabledWait for element to be enabled.net.serenitybdd.screenplay.playwright.waits.WaitForElementStateisHidden()Wait for element to be hidden (not visible or not attached).net.serenitybdd.screenplay.playwright.waits.WaitForElementStateWait for element to be visible.static net.serenitybdd.screenplay.PerformableWait for network to be idle (no pending requests for 500ms).static WaitUntilWait for an element identified by a selector.static WaitUntilWait for a Target element.static net.serenitybdd.screenplay.PerformableWait for the page to finish loading (DOMContentLoaded).static net.serenitybdd.screenplay.playwright.waits.UrlWaitBuildertheUrl()Wait for URL conditions.
-
Method Details
-
the
Wait for an element identified by a selector. -
the
Wait for a Target element. -
thePageIsLoaded
public static net.serenitybdd.screenplay.Performable thePageIsLoaded()Wait for the page to finish loading (DOMContentLoaded). -
networkIsIdle
public static net.serenitybdd.screenplay.Performable networkIsIdle()Wait for network to be idle (no pending requests for 500ms). -
allResourcesToLoad
public static net.serenitybdd.screenplay.Performable allResourcesToLoad()Wait for the page to fully load (including all resources). -
theUrl
public static net.serenitybdd.screenplay.playwright.waits.UrlWaitBuilder theUrl()Wait for URL conditions. -
isVisible
public net.serenitybdd.screenplay.playwright.waits.WaitForElementState isVisible()Wait for element to be visible. -
isHidden
public net.serenitybdd.screenplay.playwright.waits.WaitForElementState isHidden()Wait for element to be hidden (not visible or not attached). -
isAttached
public net.serenitybdd.screenplay.playwright.waits.WaitForElementState isAttached()Wait for element to be attached to DOM. -
isDetached
public net.serenitybdd.screenplay.playwright.waits.WaitForElementState isDetached()Wait for element to be detached from DOM. -
isEnabled
public net.serenitybdd.screenplay.playwright.waits.WaitForEnabled isEnabled()Wait for element to be enabled. Uses Playwright assertions which have built-in retry logic. -
isDisabled
public net.serenitybdd.screenplay.playwright.waits.WaitForDisabled isDisabled()Wait for element to be disabled. Uses Playwright assertions which have built-in retry logic. -
containsText
Wait for element to contain specific text. Uses Playwright assertions which have built-in retry logic. -
hasText
Wait for element to have specific text (exact match).
-