java.lang.Object
net.serenitybdd.screenplay.playwright.waits.WaitUntil

public class WaitUntil extends Object
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 Type
    Method
    Description
    static net.serenitybdd.screenplay.Performable
    Wait for the page to fully load (including all resources).
    net.serenitybdd.screenplay.playwright.waits.WaitForText
    Wait for element to contain specific text.
    net.serenitybdd.screenplay.playwright.waits.WaitForExactText
    Wait for element to have specific text (exact match).
    net.serenitybdd.screenplay.playwright.waits.WaitForElementState
    Wait for element to be attached to DOM.
    net.serenitybdd.screenplay.playwright.waits.WaitForElementState
    Wait for element to be detached from DOM.
    net.serenitybdd.screenplay.playwright.waits.WaitForDisabled
    Wait for element to be disabled.
    net.serenitybdd.screenplay.playwright.waits.WaitForEnabled
    Wait for element to be enabled.
    net.serenitybdd.screenplay.playwright.waits.WaitForElementState
    Wait for element to be hidden (not visible or not attached).
    net.serenitybdd.screenplay.playwright.waits.WaitForElementState
    Wait for element to be visible.
    static net.serenitybdd.screenplay.Performable
    Wait for network to be idle (no pending requests for 500ms).
    static WaitUntil
    the(String selector)
    Wait for an element identified by a selector.
    static WaitUntil
    the(Target target)
    Wait for a Target element.
    static net.serenitybdd.screenplay.Performable
    Wait for the page to finish loading (DOMContentLoaded).
    static net.serenitybdd.screenplay.playwright.waits.UrlWaitBuilder
    Wait for URL conditions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • the

      public static WaitUntil the(String selector)
      Wait for an element identified by a selector.
    • the

      public static WaitUntil the(Target target)
      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

      public net.serenitybdd.screenplay.playwright.waits.WaitForText containsText(String text)
      Wait for element to contain specific text. Uses Playwright assertions which have built-in retry logic.
    • hasText

      public net.serenitybdd.screenplay.playwright.waits.WaitForExactText hasText(String text)
      Wait for element to have specific text (exact match).