Sunday 28 September 2014

Difference between Implicit Waits and Explicit Waits

Implicit Waits :

Set implicit wait once and it apply for whole life of WebDriver object.
eg.

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);



Explicit Waits : 

- Custom code for a particular element to wait for particular time of period before executing next steps in your test.
-  Webdriver provide “WebDriverWait”, “ExpectedCondition” classes to implement this.

eg.
//explicit wait for search field
    WebDriverWait wait = new WebDriverWait(driver, 10);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("search")));

This is the basic difference between Explicit and Implicit Waits with an example.

Explicit Waits are good to use as it waits for a particular web page element on which you can apply wait.

No comments:

Post a Comment