有关如何选择和点击此代码段的两个下拉选项之一的任何想法。我在论坛中尝试了很多方法,但无法使用。提前谢谢!
<div class="dropdownButton">
<li id="Li1" class="r_dd1" onclick="showDropdown1(event,this);">
<a class="r_ddh1" id="columnYearType">10 Years</a>
<ul style="display: block;">
<li><a href="javascript:SRT_stocFund.CurrentPeriod(5, this)">5 <span class="columnType">Years</span></a></li>
<li><a href="javascript:SRT_stocFund.CurrentPeriod(10, this)">
10 <span class="columnType">
Years
</span></a>
</li>
</ul>
</li>
</div>
javascript:SRT_stocFund.CurrentPeriod 5和10年期权的xpath是:
//*[@id="Li1"]/ul/li[1]/a
//*[@id="Li1"]/ul/li[2]/a
答案 0 :(得分:0)
也许以下内容可行:
Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));
select.deselectAll();
select.selectByVisibleText("10 Years");