Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First character is missing inconstantly while sending string to the ExtJS input via sendKeys()

I randomly face the issue of missing first character in the ExtJS5 input field, while sending string via sendKeys method.

System info: Ubuntu 14.04 -> docker containers with selenium grid (2.48.2) Browser Firefox

Code is simple. I just get input web element, wait if it's clickable (i.e. isEnabled and isDisplayed), clear and send string:

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

input element is simple too:

<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've noticed that issue occurs only for the first sendKeys() executing on the page:

  • Enter the page, wait for page load, work with first input
  • Enter the page, wait for page load, choose Enable into corresponding select box in order to enable input field, work with input field (image with this example is attached)
  • Enter the page, wait for page load, click button add in order to add the needed input field, work with input field

Other occurrences of the sendKeys on the page are stable.

I've looked for similar questions. It does not seem the issue with special characters (Missing characters example: 46-> 6; coverTest -> overTest; 1 -> nothing);

Also, I don't think it's an issue with missing characters due to remote webdriver infrastructure. The tests fail randomly but in exact places.

I know that I can use sendKeys(), then check the value of the input and repeat the sending action. However, it's the last option.

Is there any additional check needed for ExtJS input (any attribute in DOM) in order to be sure that input field is ready?

Appreciate your help.

like image 635
Mike Avatar asked Jan 29 '16 14:01

Mike


1 Answers

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.

like image 105
Prateek Avatar answered Oct 20 '22 19:10

Prateek