First character is missing inconstantly while sending string to the ExtJS input via sendKeys()
Some times it happens with me. Try clicking on to the field first, but it's a wild guess assuming there can be some focus related issues.Your sequence could be somewhat like this:
wait.until(ExpectedConditions.elementToBeClickable(input)).click();input.clear();input.sendKeys(value);
Weird thing is that I actually faced a situation, where I clicked it twice before sending values and it worked somehow :P
Another thing to try could be using a non-native javascript executor.
JavascriptExecutor myExecutor = ((JavascriptExecutor) driver);myExecutor.executeScript("arguments[0].value='6';", input);
Sorry man, if the system would have been in front of me I'd have tried much more things.
I was struggling with sendKeys failing my self, but the following works pretty consistently. The method findVisibleElement
is a custom wrapper for driver.until...
.
protected static boolean sendKeysByChar(By by, String input){ WebElement field = driver.findVisibleElement(by).base(); field.click(); field.clear(); for (int i = 0; i < input.length(); i++) { String current = driver.findElement(by).getAttribute("value"); String nextChar = String.valueOf(input.charAt(i)); while (current.length() <= i || !current.endsWith(nextChar)) { field.sendKeys(nextChar); current = driver.findElement(by).getAttribute("value"); } } field = driver.findElement(by); // Refresh element if (field.getAttribute("value").equals(input)) { return true; } log.warn("Send keys by char failed."); return false;}