WebDriver - sendKeys(input) 在 sendKeys(Keys.RETURN) 之前没有完成 [英] WebDriver - sendKeys(input) does not complete before sendKeys(Keys.RETURN)

查看:49
本文介绍了WebDriver - sendKeys(input) 在 sendKeys(Keys.RETURN) 之前没有完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试是在搜索文本框中输入键,主要是 ajax,然后从键盘按 Enter.没有用于开始"搜索的按钮,因此我们使用 Enter 键.

My test is entering keys in an search text box, that's mostly ajax, and then pressing enter from the keyboard. There is no button to "start" the search so we're using the Enter key.

我正在使用 ChromeDriver,因为我们的应用程序在此流程方面不支持 Firefox.

I'm using ChromeDriver as Firefox is not supported for our application with regards to this flow.

对于我的 webdriver 代码 (java),我让它这样做:

For my webdriver code (java), I'm having it do this:

searchIcon.click(); //opens the ajax overlay of the search text box
searchBox.clear(); //clears whatever text is already there
searchBox.sendKeys(input); //enters in the input text
searchBox.sendKeys(Keys.RETURN); //press return to start the search

问题是,我注意到输入文本还没有完全输入到文本框中,并且已经发生了 RETURN.基本上,我正在搜索输入的部分输入文本.

The problem is, I noticed that the input text is not fully typed into the text box yet and the RETURN has already taken place. Basically, I'm doing a search of part of the input text that was entered.

有人遇到过这种情况吗?我尝试在 Return 操作之前添加一个隐式等待,但由于元素已经加载,这无济于事.

Anyone encountering this? I tried to add an implicitwait before the Return action but since the elements are already loaded, that isn't going to help.

推荐答案

我在执行测试时也遇到了同样的问题.并通过将 webdriver 更新到最新版本来解决.

I also encountered same issue while executing my test. And it get resolved by updating webdriver to the latest version.

webdriver-manager update --versions.chrome=2.33
webdriver-manager start --versions.chrome=2.33

这篇关于WebDriver - sendKeys(input) 在 sendKeys(Keys.RETURN) 之前没有完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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