The first character is missing continuously when sending a string to ExtJS input via sendKeys ()

I accidentally run into the problem of missing the first character in the ExtJS5 input field by sending a string using the sendKeys method.

System information: Ubuntu 14.04 → docker containers with selenium mesh (2.48.2) Firefox browser

The code is simple. I just get the web input element, waiting for it to be clickable (e.g. isEnabled and isDisplayed), clear and send the line:

wait.until(ExpectedConditions.elementToBeClickable(input)).clear();
input.sendKeys(value);

The input element is also simple:

<input id="textfield-1455-inputEl" data-ref="inputEl" type="text" role="textbox" size="1" name="name" class="x-form-field x-form-required-field x-form-text x-form-text-default x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" componentid="textfield-1455"/>

I noticed that the problem only occurs for the first start of sendKeys () on the page:

  • Enter the page, wait for the page to load, work with the first login
  • , , "" , , ( )
  • , , "", ,

sendKeys .

. ( : 46- > 6; coverTest → overTest; 1 → );

, , - webdriver. , .

, sendKeys(), . ,

, ExtJS ( DOM), , ?

.

+4
2

. , , , , . :

wait.until(ExpectedConditions.elementToBeClickable(input)).click();
input.clear();
input.sendKeys(value);

, , , , -: P

- javascript-.

JavascriptExecutor myExecutor = ((JavascriptExecutor) driver);
myExecutor.executeScript("arguments[0].value='6';", input);

, , .

+3

sendKeys, , . findVisibleElement 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;
}
0

Source: https://habr.com/ru/post/1626539/


All Articles