'How to wait untile the text box is empty selenium java?

My scenario is

  1. enter the value in the text box.
  2. click on the clear button.
  3. wait until the text box is clear.


Solution 1:[1]

try this:

public static Boolean textMatchTest(WebDriver driver, By locator, String expectedText) {
    Boolean textMatch = null;
    WebElement element = driver.findElement(locator);
    if (element.getText().equals(expectedText)) {
        textMatch = true;
    }
    else {
        try {
            new WebDriverWait(driver, 10).until(textToBe(locator, expectedText));
            textMatch = true;
        }
        catch (TimeoutException timeoutException) {
            textMatch = false;
        }
    }
    return textMatch;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pburgr