This tutorial is all about Difference Between Implicit Wait and Explicit Wait in Selenium.
An explicit wait will wait for a certain condition to occur before proceeding further in the code.There are some convenience methods provided that help you write code that will wait only as long as required. WebDriverWait in combination with ExpectedCondition is one way this can be accomplished.
Below is the standard code for Explicit Wait:
WebDriver driver = new FirefoxDriver();
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
//presenceOfElementLocated is a method inside ExpectedConditions class. You can use any
//other method apart from this based on your requirement.
This waits up to 10 seconds before throwing a TimeoutException or if it finds the element will return it in 0 – 10 seconds. WebDriverWait by default calls the ExpectedCondition every 500 milliseconds until it returns successfully. A successful return is for ExpectedCondition type is Boolean return true or not null return value for all other ExpectedCondition types.
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
Below is the standard code for Implicit Wait:[java] WebDriver driver = new FirefoxDriver();
WebElement myDynamicElement = driver.findElement(By.id(“myDynamicElement”)); [/java]
Readers might read also: