【发布时间】:2013-02-25 21:00:17
【问题描述】:
我无法让 webdriver 在基于自动完成的搜索文本字段中输入一些文本。 我正在使用以下代码:
//here elmt is a WebElement variable.
elmt = driver.findElement(By.id(testDataMap.get("globalSearchTextLocator")));
elmt.sendKeys(patientName);
//Here I am finding the search result list once webdriver enters the characters.
elmt = driver.findElement(By.cssSelector(testDataMap
.get("searchPatientNameLocator")));
searchedPatientsList = driver.findElements(By.cssSelector(testDataMap
.get("searchPatientNameLocator")));
我还尝试在elmt.sendKeys() 之前使用elmt.click()。它在我运行测试的时候随机运行了几次。但大多数情况下,它失败了。
发生的情况是 webdriver 将文本输入搜索字段并在下一刻将其清除。这导致没有搜索结果并且测试失败。我无法追踪这种奇怪行为背后的问题。有什么帮助吗?提前致谢!
【问题讨论】:
标签: autocomplete webdriver selenium-webdriver browser-automation