我試着去從下拉list.But選擇API選擇日期值失敗選擇api webdriver失敗的API?
Select date=new Select(driver.findElement(By.id("dropdown_day")));
date.selectByIndex(5);
代碼片段是
<div id="dropdown_dropdown_day" class="dropdown" role="application" style="width: 32%;">
<input id="dropdown_day" type="hidden" value="0" name="dropdown_day">
<input id="btn_dropdown_day" class="btn-m btn-ter dropdown-toggle dropdown-input" type="text" style="min-height: 19px; width: 100%;" aria-haspopup="true" name="dp_dropdown_day" aria-owns="options_dropdown_day" aria-disabled="" role="combobox" readonly="readonly" title="" value="Day">
<i class="caret-dn-dp" aria-haspopup="true"></i>
<ul id="options_dropdown_day" class="dropdown-menu-dp" style="min-width: 60px; width: 100%;" aria-hidden="true" aria-activedescendant="" role="listbox">
<li class="op" aria-selected="true" tabindex="0" role="option" op-value="0">Day</li>
<li class="op" aria-selected="false" tabindex="-1" role="option" op-value="1">01</li>
<li class="op" aria-selected="false" tabindex="-1" role="option" op-value="2">02</li>
<li class="op" aria-selected="false" tabindex="-1" role="option" op-value="3">03</li>
<li class="op" aria-selected="false" tabindex="-1" role="option" op-value="3">...</li>
<li class="op" aria-selected="false" tabindex="-1" role="option" op-value="4">31</l
</ul>
什麼是失敗錯誤? – irla
線程「main」中的異常org.openqa.selenium.support.ui.UnexpectedTagNameException:元素應該是「選擇」但是是「輸入」 構建信息:版本:'2.37.0',修訂版本:'a7c61cb',時間:'2013-10-18 17:15:02' os.name:'Windows Vista',os.arch:'x86',os.version:'6.0',java.version:'1.7.0_45' 驅動程序info:driver.version:unknown \t at org.openqa.selenium.support.ui.Select。 (Select.java:46) –