What are the exact differences between implicitwait(), explicitwait() and fluentwait()? Could you explain with examples?
Implicit Waits:
An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element if they are not immediately available.WebDriver will wait for mentioned time and it will not try to find the element again during the specified time period. Once the specified time is over, it will try to search the element once again the last time before throwing exception.The major disadvantage is time is lot as driver waits for the specified time before proceeding
Explicit wait
There can be a situation when a particular element takes more than a minute to load in this situation you can you can simply put a separate time on the required element only. By following this your browser implicit wait time would be short for every element and it would be large for specific element.The default polling period is 500 milliseconds ie)it will check for the element for every 500 milliseconds interval.
Fluent wait If you have an element which sometime appears in just 1 second and some time it takes minutes to appear. In that case it is better to use fluent wait, as this will try to find element again and again until it find it or until the final timer runs out.you can set the polling time in fluent wait The user can also configure the wait to ignore specific types of exceptions such as NosuchElementException
// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 5 seconds.
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
})