Wait For Element To Be Available On Webpage Using Selenium WebDriverWait

Application may take some time to load some elements due to internet connection or any other factor, due to which the selenium script can be failed. To avoid script failure we can wait for an element to be available on webpage, the below code will wait for a maximum of 30 seconds for the element to be available.
  1. WebDriverWait wait = new WebDriverWait(driver, 30);  
  2. WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("id123")));