Synchronizing a test with an explicit wait

The Selenium WebDriver provides an explicit wait for synchronizing tests, which provides a better way to wait over an implicit wait. Unlike an implicit wait, you can write and use pre-defined conditions or custom conditions for wait before proceeding further in the code.

The Selenium WebDriver provides the WebDriverWait and ExpectedConditions classes to implement an explicit wait.

The ExpectedConditions class provides a set of predefined conditions to wait for before proceeding further in the code. The following table shows some common conditions that we frequently come across when automating web browsers supported by the ExpectedConditions class:

Predefined condition

Selenium method

An element is visible ...

Get Selenium Testing Tools Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.