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

Differences in Code

Implicit Wait

Explicit 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

  • 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

Explicit Wait

  • Throws a WebDriverTimeoutException, depending on your expected condition

 

Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones, community, and the world at large. Today, he serves as the CEO and Test Automation Instructor at UltimateQA.com and contributes informative articles to leading test automaton websites like SimpleProgrammer.com and TechBeacon.com

Pin It on Pinterest

Shares
Share This