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 and enabled |
|
An element is selected |
|
Presence of an element |
|
Specific text present in an element |
|