WebDriverWait In Selenium | Selenium WebDriver Tutorial

Selenium WebDriverWait is one of the Explicit waits.

Explicit waits are confined to a particular web element. Explicit Wait is code you define to wait for a certain condition to occur before proceeding further in the code.

Explicit wait is of two types:

  1. WebDriverWait
  2. FluentWait

Click on this link for FluentWait.

WebDriverWait In Selenium:

It is applied on certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw exception when element is not found.

We could avoid throwing exception in Selenium. Check this post.

The following are the Expected Conditions that can be used in Explicit Wait

  1. alertIsPresent()
  2. elementSelectionStateToBe()
  3. elementToBeClickable()
  4. elementToBeSelected()
  5. frameToBeAvaliableAndSwitchToIt()
  6. invisibilityOfTheElementLocated()
  7. invisibilityOfElementWithText()
  8. presenceOfAllElementsLocatedBy()
  9. presenceOfElementLocated()
  10. textToBePresentInElement()
  11. textToBePresentInElementLocated()
  12. textToBePresentInElementValue()
  13. titleIs()
  14. titleContains()
  15. visibilityOf()
  16. visibilityOfAllElements()
  17. visibilityOfAllElementsLocatedBy()
  18. visibilityOfElementLocated()

Must Read: Waits in Selenium – Implicit, Explicit, FluentWait


Test script with an explanation:

Find the sample script (using Java) mentioned below. Execute it to see the functionality.

The default pooling period for implicit and explicit wait is 250 ms. Here in Fluent wait, we could change the default pooling period based on our requirement. Also we could ignore any exception while pooling element such as No Such Element exception.

If you are not regular reader of my blog then I highly recommend you to sign up for the free email newsletter using the below link.

WebDriverWait In Selenium

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap