Confused about all of the different Selenium Webdriver Timeouts? This post will help you to understand the difference between an Explicit and Implicit Wait.
Difference In Definition
- Tell Webdriver to poll the DOM for a certain amount of time. This is literally using the ImplicitlyWait() method that Selenium Webdriver offers.
- Only needs to be configured once
- Less flexible
- This is the code that you write to wait for a certain condition to occur before proceeding. You can use the WebDriverWait class, Thread.Sleep, or write your own from scratch.
- Recommended way to wait in your tests
- Selenium will try an action repeatedly until the action can be accomplished or an exception is thrown
Differences in Code
Differences in Default Wait Time
Implicit Default Timeout (sec) – 0
Explicit Default Timeout (sec) – .5
Default Wait Timeout – depends on your implementation
Difference In Exceptions Thrown
- Throws a NoSuchElementException when the element is not present in the DOM
- Throws a ElementNotVisibleException when element is present in the DOM, however, it is hidden and cannot be interacted with
- Throws a WebDriverTimeoutException, depending on your expected condition