Reputation: 491
org.openqa.selenium.TimeoutException: Expected condition failed: (tried for 10 second(s) with 500 MILLISECONDS interval)
here is my code:
public static ExpectedCondition<Boolean> waitForTextToChange(final WebElement element, final String currentText) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver arg0) {
return !element.getText().equals(currentText);
}
};
}
use code:
WebElement element = driver.findElement(...);
String currentText = element.getText();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(waitForTextToChange(element, currentText));
Upvotes: 0
Views: 81
Reputation: 41
The execution is failed because the command did not complete in enough time. It could be that you need to 1) extend the time you wait for the text to appear, or 2) maybe the element you are looking at doesn't display text in the way you expect. You should debug and see what element.getText() is returning. You are using equals, so the text has to match exactly. If you have any whitespace or lowercase versus uppercase issues, the text will not match. There are a number of different reasons why this is timing out. You should add a try/catch and debug with breakpoints to see what exactly is going on in your code.
Upvotes: 1