通过sendKeys()将字符串发送到ExtJS输入时,第一个字符会不断丢失 [英] First character is missing inconstantly while sending string to the ExtJS input via sendKeys()

查看:90
本文介绍了通过sendKeys()将字符串发送到ExtJS输入时,第一个字符会不断丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过sendKeys方法发送字符串时,我随机遇到ExtJS5输入字段中缺少第一个字符的问题.

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

系统信息:Ubuntu 14.04->具有Selenium网格的Docker容器(2.48.2)浏览器Firefox

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

代码很简单.我只是得到输入的Web元素,请等待它是否可单击(即isEnabled和isDisplayed),清除并发送字符串:

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 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"/>

我注意到仅在页面上执行的第一个sendKeys()会发生此问题:

I've noticed that issue occurs only for the first sendKeys() executing on the page:

  • 进入页面,等待页面加载,使用第一个输入
  • 进入页面,等待页面加载,在相应的选择框中选择启用"以启用输入字段,并使用输入字段(此示例的图片已附加)
  • 进入页面,等待页面加载,单击添加按钮以添加所需的输入字段,并使用输入字段

页面上出现的其他sendKeys都很稳定.

Other occurrences of the sendKeys on the page are stable.

我一直在寻找类似的问题.特殊字符似乎没有问题(缺少字符示例:46-> 6; coverTest-> overTest; 1->没什么);

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

此外,由于远程Webdriver基础结构,我认为这不是缺少字符的问题.测试随机失败,但在准确的地方.

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.

我知道我可以使用sendKeys(),然后检查输入的值并重复发送操作.但是,这是最后的选择.

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.

是否需要对ExtJS输入(DOM中的任何属性)进行其他检查,以确保输入字段准备就绪?

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

感谢您的帮助.

推荐答案

有时候是发生在我身上.尝试先单击该字段,但假设存在一些与焦点相关的问题,这是一个很大的猜测.您的序列可能有点像这样:

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);

奇怪的是,我实际上遇到了一种情况,在发送值之前我单击了两次,它以某种方式起作用:P

Weird thing is that I actually faced a situation, where I clicked it twice before sending values and it worked somehow :P

要尝试的另一种方法是使用非本地 javascript执行程序.

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.

这篇关于通过sendKeys()将字符串发送到ExtJS输入时,第一个字符会不断丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆