<input class="dropdown" type="text" value="Choose option" data-activates="select-123" readonly="true">
<ul id="select-123" class="content dropdown" style="width: 11px; position: absolute; top: 0px; left: 0px; opacity: 1; display: none;">
<li class="please-select" style="display:none;">
<span>Choose option</span>
</li>
<li class="">
<span>city</span>
</li>
<li class="">
<span>state</span>
</li>
<li class="">
<span>country</span>
</li>
</ul>
点击&#34;选择选项&#34;上面的代码更改为:
<input class="dropdown active" type="text" value="Choose option" data- activates="select-123" readonly="true">
<ul id="select-123" class="content dropdown active" style="width: 11px; position: absolute; top: 0px; left: 0px; opacity: 1; display: block;">
<li class="please-select" style="display:none;">
<span>Choose option</span>
</li>
<li class="">
<span>City</span>
</li>
<li class="">
<span>State</span>
</li>
<li class="">
<span>Country</span>
</li>
</ul>
使用selenium javascript webdriver我试图选择&#34; State&#34;选项。
driver.findElement(By.css(".dropdown[value='Choose option']")).click();
driver.wait(until.elementLocated(By.xpath("//ul[@class='content dropdown active']/li[3]")), 3000);
driver.findElement(By.xpath("//ul[@class='content dropdown active']/li[3]")).click();
&#34;选择选项&#34;单击,我看到3个选项。但是硒无法选择&#34; State&#34;选项。
错误是:
NoSuchElementError:没有这样的元素:无法找到元素:{&#34;方法&#34;:&#34; xpath&#34;,&#34;选择器&#34;:&#34; // ul [ @class =&#39;内容下拉列表有效&#39;] / li [3]&#34;}