Java Selenium WebDriver_下拉列表中列出的元素无法选择

Java Selenium WebDriver_下拉列表中列出的元素无法选择,java,selenium,webdriver,Java,Selenium,Webdriver,您好,我找不到以下下拉列表元素。以下是HTML代码: <div class="FormDetails"><br> <ul class="lsn"><br> <li><br> <span id="errfileName"></span><br> </li><br> <li style="display: block;"><br> <div

您好,我找不到以下下拉列表元素。以下是HTML代码:

<div class="FormDetails"><br>
<ul class="lsn"><br>
<li><br>
<span id="errfileName"></span><br>
</li><br>
<li style="display: block;"><br>
<div class="LeftSection-Form" style="margin-bottom: 15px;"><br>
<div class="FormLabel"><br>
<Community<br>
<span class="FormDetails_required"> Required</span><br>
</div><br>
<div class="FormValue"><br>
<select id="Fact-Communities-LIVE" class="ToolTipPopup Sel1355" tooltip-title=<p>"Community "</p> onkeydown="return preventBackspace(event);" <br>onchange="dropDownValue(this);" name="Fact.Communities.LIVE" emptyoption="-Please select-"><br>
    <option value="TxnyD.PleaseSelect.1.1">-Please select-</option><br>
    <option value="TxnyD.Communities.1.1">UVDB</option><br>
    <option value="TxnyD.Communities.2.1">THQS</option><br>
    <option value="TxnyD.Communities.3.1">Master</option><br>
    <option value="TxnyD.Communities.4.1">Connexio</option><br>
    <option value="TxnyD.Communities.5.1">SL</option><br>
    <option value="TxnyD.Communities.6.1">OG</option><br>
    <option value="TxnyD.Communities.7.1">UT</option><br>
    <option value="TxnyD.Communities.8.1">TR</option><br>
    <option value="TxnyD.Communities.9.1">FGW</option><br>
    <option value="TxnyD.Communities.10.1">E.ON TSMS</option><br>
    <option value="TxnyD.Communities.11.1">Vattenfall TSMS</option><br>
    <option value="TxnyD.Communities.12.1">Delivery1</option><br>
    <option value="TxnyD.Communities.13.1">Test community</option><br>
    <option value="TxnyD.Communities.14.1">Automotive</option><br>
    <option value="TxnyD.Communities.15.1">SHELL SUPPLIER QUALIFICATION SYSTEM</option> <br>
    <option value="TxnyD.Communities.17.1">Nestle</option><br>
    <option value="TxnyD.Communities.18.1">BuildingConfidence</option><br>
</select><br>
</div><br>
</div><br>
我也试过这些:

//driver.findElement(By.id("Fact-Communities-LIVE")).sendKeys("SHELL SUPPLIER QUALIFICATION SYSTEM");
//Thread.sleep(1000);
//new Select(driver.findElement(By.id("Fact-Communities-LIVE"))).selectByVisibleText("SHELL SUPPLIER QUALIFICATION SYSTEM");
&这些也是

//WebElement dropDown = driver.findElement(By.xpath(".//*[@id='Fact-Communities-LIVE']"));
//List<WebElement> options = dropDown.findElements(By.xpath(".//*[@id='Fact-Communities-LIVE']/option[16]/text()"));
//driver.findElement(By.xpath(".//*[@id='Fact-Communities-LIVE']/option[16]")).click();
//WebElement dropDown=driver.findElement(By.xpath(“.//*[@id='Fact-Communities-LIVE']”);
//列表选项=dropDown.findElements(By.xpath(“./*[@id='Fact-Communities-LIVE']]/option[16]/text()”);
//driver.findelelement(By.xpath(“./*[@id='Fact-Communities-LIVE']]/option[16]”);
但似乎有什么地方出了问题,请任何人给我指点一下

使用选择类:

Select select = new Select(driver.findElement(By.Id("Fact-Communities-LIVE");
然后使用要选择的选项,按值、按文本、按索引等进行选择。 同时检查html上的所有标记是否正确打开和关闭

请尝试下面的代码

WebElelment dropDown = driver.findElement(By.id("Fact-Communities-LIVE"));
new Select(dropDown).selectByVisibleText("SHELL SUPPLIER QUALIFICATION SYSTEM");
or 
new Select(dropDown).selectByValue()("TxnyD.Communities.15.1");

我对相同的
driver.findElement(By.xpath(“./*[@id='Fact-Communities-LIVE']/option[16]/text()='SHELL供应商资格认证系统'))使用了以下xpath;您的HTML格式不正确,这将导致XPath出现问题。您的工具提示标题属性(我从未听说过)的格式不正确,因为等号的右侧没有后跟双引号(“)。此外,在title属性中包含HTML有点奇怪。您的select元素中还嵌入了一些HTML,而这些HTML根本不应该存在。

标记不需要跟在
元素后面(实际上是无效的)在
中。首先尝试修复这些问题。观察到以下错误:在org.openqa.selenium.remote.RemoteWebDriver.findelelement(RemoteWebDriver.java:299)在TestClass1.main(TestClass1.java:26)由以下原因引起:rg.openqa.selenium.remote.ErrorHandler$UnknownServerException:无法找到元素:{“方法”:“名称”,“选择器”:“UploadNew”}构建信息:版本:'2.39.0',版本:'ff23eac',时间:'2013-12-16 16:11:15'系统信息:主机:'ABGPC0066',ip:'10.187.3.191',os.name:'Windows 7',os.arch:'x86',os.version:'6.1',java.version:'1.8.0_20'驱动程序信息:驱动程序版本:未知
WebElelment dropDown = driver.findElement(By.id("Fact-Communities-LIVE"));
new Select(dropDown).selectByVisibleText("SHELL SUPPLIER QUALIFICATION SYSTEM");
or 
new Select(dropDown).selectByValue()("TxnyD.Communities.15.1");