RE: FluentWait-condition not evaluating to true

I wrote this code based on your example  but the condition never evaluate to true so it keeps on printing “Buzz  Buzz”.

public class FluentWaitCommands {

private static WebDriver driver = null;

public static void main(String[] args) {

driver = new FirefoxDriver();

WebElement element = driver.findElement(“clock”));

FluentWait<WebElement> wait = new FluentWait<WebElement>(element);

wait.withTimeout(600, TimeUnit.SECONDS);
wait.pollingEvery(500, TimeUnit.MILLISECONDS);

Function <WebElement, Boolean> f = new Function <WebElement, Boolean> () {
public Boolean apply (WebElement element) {

if (!element.getText().equals(“Buzz Buzz”))
String value = element.getText();
System.out.println(“Value of the element is: ” + value);
return false;

System.out.println(“Hurray found Buzz Buzz :D”);
return true;




Add Comment
4 Answers

Is it possible to solve just by .until and ExpectedConditions class instead of until()’s overloaded method with Function and Predicate? I mean something like this:

public void testTextDisplayed(WebDriver driver){


WebElement element = driver.findElement(By.className("timer"));
WebDriverWait wait = new WebDriverWait(driver, 45);

wait.pollingEvery(100, TimeUnit.MILLISECONDS);

boolean isBuzzBuzz = wait.until(ExpectedConditions.textToBePresentInElementValue(element, "Buzz Buzz"));

System.out.println("Buzz Buzz is present!");



System.out.println("Buzz Buzz us not present yet.");


Default Answered on May 17, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.