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
- Implicit Wait
- 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
- Explicit Wait
- 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
- Default Wait – This class allows you to specify the polling interval, the message, exceptions to ignore, and much more.
Differences in Code
Default Wait aka Fluent Wait
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
Implicit Wait thows a NoSuchElementException
Explicit Wait throws a WebDriverTimeoutException