What is the maximum time taken by WebElement.isDisplayed()
method to search for visibility of an element?
Can we define the time without using implicit wait?
What is the maximum time taken by WebElement.isDisplayed()
method to search for visibility of an element?
Can we define the time without using implicit wait?
The isDisplayed()
method is immediate, and you can't set the time for it. Implicit wait is used to tell the driver
what is the maximum amount of time it should try to locate the element, i.e. the element exists in the DOM. It doesn't means (although very much possible) the element is visible.
If you want to increase the amount of time you are willing to wait for element to be visible you can use explicit wait to wait for the element to be visible.
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id")));
First of all you should reduce the time of implicit wait, and still if is display taking time u can use this code. driver.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
for(int i=0; i<2; i++) {
try {
String signin = driver.findElement(By.id("xpath"));
System.out.println(signin);
break;
} catch (Exception e) {
// TODO: handle exception
System.out.println("element not display");
}
}