liveBook · Manning

ExpectedConditions

As explained in BDD in Action, Second Edition

ExpectedConditions is a Selenium utility class providing predefined predicates for common browser-state conditions.

ExpectedConditions is a Selenium utility class containing predefined predicates for synchronizing browser tests with changing page state. Used with WebDriverWait, it prevents assertions from running before asynchronous UI changes complete. section 10.2.15

Wait for a transient success message

After login, wait up to five seconds for the `.toast-success` element to become visible, then retrieve its text and assert the expected email. The wait can return the element directly, allowing immediate interaction. section 10.2.15

ExpectedConditions handles common synchronization needs; more specific behavior can use a custom wait function. Selenium conditions can also be accessed while expressing waits through Screenplay tools. section 10.2.15 section 12.5.3

How BDD in Action, Second Edition covers it

How deep it goes
Defines common visibility, presence, text, disappearance, count, and title predicates, then stops short of application-specific conditions.
Examples
Uses a transient Toastr login message, visibilityOfElementLocated(), returned elements, and flight-search result conditions.
What it assumes
Assumes Selenium WebDriver and locators, while introducing explicit waits for asynchronous page behavior.
What you can do after
Apply it via Selenium Java waits to synchronize UI tests and inspect elements once their required state is reached.
How it connects
Connects explicit waits, WebDriverWait, fluent waits, custom wait functions, and the Screenplay Pattern.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.