朋友们,
我有一种情况,我需要单击下拉列表并选择显示的任何值。下拉列表由以下代码段标识
<select id="order_unit_line_rate_806782_is_addenda_enabled" class="selects_for_487886" onchange="select_addendum(806782, this);dateShowMemory(this.options[this.selectedIndex].value, '806782');" uniqueattr="Dynamic Site Accelerator / Dynamic Site Accelerator / Additional Usage Commitment / drop down" name="order_unit_line_rate[806782][is_addenda_enabled]">
<option value="0" uniqueattr="Dynamic Site Accelerator / Dynamic Site Accelerator / Additional Usage Commitment / Fee"> Fee </option>
<option value="1" uniqueattr="Dynamic Site Accelerator / Dynamic Site Accelerator / Additional Usage Commitment / See Attached Addendum"> See Attached Addendum </option>
其中“选择”和“选项”标签位于嵌套层次结构中。我可以单击下拉列表并通过这样做来显示项目
List<WebElement> dropDownLists = driver.findElements(By.tagName("select"));
for (WebElement l : dropDownLists) {
if (l.getAttribute("uniqueattr").equalsIgnoreCase("Dynamic Site Accelerator / Dynamic Site Accelerator / Additional Usage Commitment / drop down")) {
l.click();
} // end if
} // end for
但是我无法进一步遍历以单击下拉列表中的选项:(。
这是我尝试过的,但不起作用
List<WebElement> newList = driver.findElements(By.tagName("option"));
for (WebElement ll : newList) {
if (ll.getAttribute("uniqueattr").equalsIgnoreCase("Dynamic Site Accelerator / Dynamic Site Accelerator / Additional Usage Commitment / Straight Line Commitment")) {
ll.click();
}
}