下面是下拉菜单的HTML代码
<div class="comboBox" id="ATFType-main" nativeid="ATFType" iseditabletablecombo="false" style="left: 165px; top: 105px; width: 156px;">
<a tabindex="75" data-tab="75" style="outline: medium none;" id="ATFType-box" class="comboBox_box" href="#">
<span class="comboBox_inputs comboBox-mandatory-input " id="ATFType-input" title="" aria-required="true" style="width: 140px;"></span>
<span class="comboBox_buttons comboBox-mandatory-btn " aria-haspopup="true" aria-owns="ATFType-lists" id="ATFType-button" tabindex="-1"></span>
</a>
<div class="comboBox_divs comboBox_corner-all" id="ATFType-div" style="height: 36.4px; width: 158px; overflow: hidden; display: none;">
<ul class="comboBox_list comboBox-mandatory " aria-hidden="true" aria-labelledby="ATFType-button" role="listbox" id="ATFType-lists" stylecomputed="true">
<li data-value="" data-index="0" class="comboBox_lielements comboBox_active"></li>
<li data-value="ATFR" data-index="1" class="comboBox_lielements">Account Transfer</li>
</ul>
</div>
</div>
通过点击 span 下拉列表将显示。下拉值在 li
内如何选择li中提到的选项。我们只有范围ID。
答案 0 :(得分:0)
使用以下解决了此问题。
代码段:
{
webElementName.click();
String xpath="//*[@id='"+webElementId+"']//following::li[contains(text(),'"+FieldValue+"')]";
driver.findElement(By.xpath(xpath)).click();
}