wait until element is visible selenium java
If you have a scenario of selenium wait for element to be visible on the software web page then selenium webdriver/Selenium 2 has its own method named visibilityOfElementLocated(By locator) to check the visibility of an element on the software web page. We can use this method with explicit webdriver wait condition to selenium wait element visible on the page. However, we can wait for an element to be clickable using elementToBeClickable(By locator) method as described in THIS ARTICLE.
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='text3']")));
Here is a practical example of waiting until the element is visible selenium java. Execute it once and then use it for your software web application test scenario.
Copy below the given @Test method part of the wait for visibility of the element located example and replace it with the @Test method part of the example given on THIS PAGE. (Note: @Test method is marked with pink color in that linked page).
Example of wait until element is visible selenium java
@Test
public void test () throws InterruptedException, IOException
{
//To wait for element visible
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='text3']")));
driver.findElement(By.xpath("//input[@id='text3']")).sendKeys("Text box is visible now");
System.out.print("Text box text3 is now visible");
}