This is my solution to send text for input:
public void sendKeysToElement(WebDriver driver, WebElement webElement, String text) { WebDriverWait wait = new WebDriverWait(driver, Configuration.standardWaitTime); try { wait.until(ExpectedConditions.and( ExpectedConditions.not(ExpectedConditions.attributeToBeNotEmpty(webElement, "value")), ExpectedConditions.elementToBeClickable(webElement))); webElement.sendKeys(text); wait.until(ExpectedConditions.textToBePresentInElementValue(webElement, text)); activeElementFocusChange(driver); } catch (Exception e) { Configuration.printStackTraceException(e); } } WebElement nameInput = driver.findElement(By.id("name")); sendKeysToElement(driver, nameInput, "some text");
source share