Selenium sendKeys(string) 方法只发送部分字符串
·
问题:Selenium sendKeys(string) 方法只发送部分字符串
我使用sendKeys
方法将字符串发送到搜索框。问题是只有第一对(不同的)密钥被发送。结果是搜索框无法正确过滤内容。下面是我的代码片段:
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 u003d "test lab" 只有 currLab 的 "te" 被发送到过滤器框。
编辑:只需添加 selectLab 由于未发送全文而选择了不正确的项目。
解答
看来我没有给司机足够的时间来送钥匙。在尝试选择和项目之前,我添加了一个 sleep(1000) 。现在工作正常。
更多推荐
所有评论(0)