Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
如何处理Selenium中具有下拉列表的自动提示文本字段? 有一个名为“选择一个行业”的文本字段,点击它会显示下拉列表_Selenium_Xpath_Autocomplete_Dropdown_Autosuggest - Fatal编程技术网

如何处理Selenium中具有下拉列表的自动提示文本字段? 有一个名为“选择一个行业”的文本字段,点击它会显示下拉列表

如何处理Selenium中具有下拉列表的自动提示文本字段? 有一个名为“选择一个行业”的文本字段,点击它会显示下拉列表,selenium,xpath,autocomplete,dropdown,autosuggest,Selenium,Xpath,Autocomplete,Dropdown,Autosuggest,附加ref的屏幕截图您发布的代码有几个问题。稍微清理一下就可以了,但是Selenium通过Select提供了一些方法,您应该利用这些方法 String expectedValue = "Adverstising Services"; Select dropDown = new Select(driver.findElement(By.xpath(".//*[@id='select2-chooseInd-container']"))); dropDown.selectByVisibleText(e

附加ref的屏幕截图

您发布的代码有几个问题。稍微清理一下就可以了,但是Selenium通过
Select
提供了一些方法,您应该利用这些方法

String expectedValue = "Adverstising Services";
Select dropDown = new Select(driver.findElement(By.xpath(".//*[@id='select2-chooseInd-container']")));
dropDown.selectByVisibleText(expectedValue);

您可以阅读有关
Select
和文档中提供的方法的更多信息,此处:

您需要
ActionChains
首先将光标设置在下拉菜单上,然后单击所需选项Anks Anderson。你能详细说明一下吗?这样可以帮助我理解你指定的编程语言use@Andersson:我使用javajavai,它可能与