Synchronizing a test with an explicit wait
The Selenium WebDriver also provides an explicit wait for synchronizing tests, which provides a better control when compared with an implicit wait. Unlike an implicit wait, you can write custom code or conditions for wait before proceeding further in the code.
An explicit wait can only be implemented in cases where synchronization is needed and the rest of the script is working fine.
The Selenium WebDriver provides WebDriverWait and ExpectedCondition classes for implementing an explicit wait.
The ExpectedCondition class provides a set of predefined conditions to wait 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 ExpectedCondition class:
|
Predefined condition |
Selenium method |
|---|---|
|
An element is visible and enabled |
|
|
An element is selected |
|
|
Presence of an element... |