Synchronizing Selenium Webdriver with Application using implicit and Explicit Waits

    To make synchronize webdriver with application we have three ways in selenium.

  1. impliciteWait : If we use implicitlyWait(20, TimeUnit.SECONDS) method, then the  driver will wait up to 20( or more) seconds , if object is available meanwhile,then the next operation will be performed, it won't consider about object state like enabled, disable or clickable , editable etc…

if object not identified in given time then exception will be thrown..


Sample Code :   

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


  1. expliciteWait : If we use ExpectedConditions method in  WebDriverWait Interface,then the driver will wait up to 20( or more) seconds , if object is available meanwhile,then the next operation will be performed,and  it will consider about object state like enabled, disable or clickable , editable etc…

if object not identified in given time then exception will be thrown..


Sample Code:

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));


  1. Thread.sleep(long milliSeconds) : Here  sleep(long milliSeconds) method will pause the execution until given time completed..next operation will not be performed even the object is available in page. generally we use this when even next page object is available in current page also.


Sample Code: Thread.sleep(3000); //Pause execution 3 seconds