我使用 sendKeys
方法将字符串发送到搜索框。问题是
仅发送第一对(不同的) key 。结果是搜索框无法正确过滤内容。下面是我的代码片段:
String currLab = labsInCloud.get(j); //get a lab name from a list
evtFilter_fld.clear(); //clear the filter box
evtFilter_fld.sendKeys(currLab); //send keys to filter box
WebElement selectLab = getDriver().findElement(mainPage_selectLab_i(1)); //select first item from
//filter
例如,如果 currLab = "test lab" 仅将 currLab 的“te”发送到过滤框。
编辑:只是补充一下,由于未发送全文,selectLab 选择了不正确的项目。
最佳答案
我遇到了这个问题,这是我的键盘映射问题。
我的特殊情况是在桌面环境中通过 VNC 运行测试。我使用的是 tightvncserver,它错误地加载了键盘。切换到 vnc4server 解决了问题。
关于java - Selenium sendKeys(string) 方法只发送部分字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26511741/