Below is my code
public boolean waitForElementToBeClickable(String xpathValue){
Boolean flag = false;
WebElement myDynamicElement = (new WebDriverWait(Base.base.getDriver(), 30))
.until(ExpectedConditions.elementToBeClickable(By.xpath(xpathValue)));
flag = true;
return flag;
}
This wait for element to appear for 30 sec and if element is ready before 30 sec it perform the next command.
but when I use below code for fluent wait
public Boolean waitForElementToAppear(final WebElement e){
Wait<WebElement> wait = new FluentWait<WebElement>(e)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
;
Boolean foo = wait.until(new Function<WebElement, Boolean>() {
public Boolean apply( WebElement element) {
return element.isDisplayed();
}
});
return foo;
}
It says No-such Element exception, it doesn't even wait for 30 sec, it throw exception instantly.
Can someone tell what is the issue with it ?