我有一個下拉列表,我無法從中選擇項目。我可以遍歷列表中的所有項目並找到我想要的項目,但click()不選擇項目。無法在下拉列表中選擇項目
這是代碼。任何人都可以幫忙嗎?
driver.findElement(By.id("components-multi-select")).findElement(By.className("icon")).click();
driver.findElement(By.id("components-suggestions"));
List<WebElement> componentList = driver.findElements(By.className("aui-list-item"));
for (WebElement component : componentList){
System.out.println(component.getText());
if (component.getText().contains(newComponent)){
component.click();
break;
}
else{
System.out.println("not equal");
}
這是組件下拉列表的html代碼。
<div class="field-group aui-field-componentspicker frother-control-renderer" >
<label for="components">Component/s</label>
<div class="ajs-multi-select-placeholder textarea long-field"></div>
<select class="select hidden " id="components" multiple="multiple" name="components" size="5" data-remove-null-options="true">
<option value="-1">
Unknown
</option>
<option selected="selected" title="Component 1 - A test component" value="10240">
Component 1
</option>
<option title="Component 2 - " value="10242">
Component 2
</option>
<option title="Lee 2 " value="10371">
Lee 2
</option>
<option title="Roy " value="10370">
Roy
</option>
<option title="Test Documentation " value="10241">
Test Documentation
</option>
</select>
你能發佈一個包含列表的html的一部分嗎?看起來這個列表是某種3d方的小部件 – 2010-11-25 12:40:37