new WebDriverWait(driver,180).pollingEvery(10, TimeUnit.SECONDS).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'sweet-alert')]/p")));

new FluentWait(driver).withTimeout(180, TimeUnit.SECONDS).pollingEvery(10,TimeUnit.SECONDS)

Please have a look at the above two waits. both are going to wait for maximum 180 seconds and both are going to check for element every 10 seconds then how do they differ?

Thanks, Pradeep


If you view the source for WebDriverWait you can see that it extends the FluentWait<WebDriver> class.

Ultimately, if you're using the FluentWait<WebDriver> it is the same just uses some defaults in the constructors from what I can tell. I'd use WebDriverWait over FluentWait for multiple reasons but primarily due to it being the most familiar implementation. If there is extensions built that you wish to use they are more likely to use the WebDriverWait than the FluentWait, which will likely cause you problems.

Now if you wanted to use, for example, FluentWait<WebElement>, this might be beneficial.

Not the answer you're looking for? Browse other questions tagged or ask your own question.