Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autocomplete sendkeys()在自动完成搜索字段中输入并清除文本_Autocomplete_Webdriver_Selenium Webdriver_Browser Automation - Fatal编程技术网

Autocomplete sendkeys()在自动完成搜索字段中输入并清除文本

Autocomplete sendkeys()在自动完成搜索字段中输入并清除文本,autocomplete,webdriver,selenium-webdriver,browser-automation,Autocomplete,Webdriver,Selenium Webdriver,Browser Automation,我无法让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

我无法让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将文本输入搜索字段,并在下一刻将其清除。这将导致没有搜索结果并导致测试失败。我无法追踪这种奇怪行为背后的问题。有什么帮助吗?提前谢谢

我遇到过类似的问题,但它是针对数字领域的。尝试使用下面的代码并执行您的脚本

String accOffNoID = OR.getProperty("AccOffNo_ID"); 
        WebElement accOffNoInput = driver.findElement(By.id(accOffNoID));
        accOffNoInput.clear(); 
        accOffNoInput.sendKeys(String.valueOf(9874651230L));
        accOffNoInput = driver.findElement(By.id(accOffNoID));
根据脚本更改名称并执行,它应该可以工作