這是下拉的圖片的鏈接: http://i.stack.imgur.com/tQs4Z.png硒的webdriver(2.0) - 多選擇[複選框]下拉菜單 -
我一直在研究這個了一下,但一直未能找到一個合適的解下拉列表中可以選中複選框。多選可能。下面是下拉菜單的HTML,其中包含「必填字段」星號和下拉菜單的標題。抱歉格式化出來時髦。
我相信如果它是一個Select元素會更容易,但是因爲它是一個Input,所以我想伸手去看看處理這些元素的最佳方式。我應該提到,我正在使用WebDriver for MS Visual Studio 2010 C#。
此外,我發現this其中,雖然相關,似乎沒有與複選框下拉菜單。
<tr>
<td align="right" valign="top" style="background-color:White;">
<span id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_lblRequired" class="RequiredIndicator">*</span>
</td>
<td valign="top" style="background-color:White;">2</td>
<td valign="top" style="background-color:White;">Question 2 Cities?</td>
<td align="left" valign="top" style="border-color:White;border-width:1px;border-style:Solid;">
<input type="hidden" name="ctl03$ctl00$ctl00$Tabbed_ContentPlaceHolder$ContentPlaceHolder1$ContentPlaceHolder1$ctl00$ctl00$gvQuestions$ctl03$hdnQId" id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_hdnQId" value="2">
<input type="hidden" name="ctl03$ctl00$ctl00$Tabbed_ContentPlaceHolder$ContentPlaceHolder1$ContentPlaceHolder1$ctl00$ctl00$gvQuestions$ctl03$hdnVId" id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_hdnVId" value="3">
<input type="hidden" name="ctl03$ctl00$ctl00$Tabbed_ContentPlaceHolder$ContentPlaceHolder1$ContentPlaceHolder1$ctl00$ctl00$gvQuestions$ctl03$hdnAId" id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_hdnAId" value="3">
<div id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2" class="RadComboBox RadComboBox_Classic" style="width:150px;white-space:normal;">
<table summary="combobox" border="0" style="border-width: 0px; border-collapse: collapse; width: 150px;">
<tbody>
<tr>
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
<input name="ctl03$ctl00$ctl00$Tabbed_ContentPlaceHolder$ContentPlaceHolder1$ContentPlaceHolder1$ctl00$ctl00$gvQuestions$ctl03$cblListItems2" type="text" class="rcbInput radPreventDecorate" id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2_Input" value="" autocomplete="off">
</td>
<td class="rcbArrowCell rcbArrowCellRight">
<a id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
</td>
</tr>
</tbody>
</table>
<div class="rcbSlide" style="z-index:6000;">
<div id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Classic " style="display:none;">
<div class="rcbScroll rcbWidth" style="width:100%;">
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">
<li class="rcbItem"><label><input type="checkbox" class="rcbCheckBox">Denver</label></li>
<li class="rcbItem"><label><input type="checkbox" class="rcbCheckBox">Los Angeles</label></li>
<li class="rcbItem"><label><input type="checkbox" class="rcbCheckBox">New York City</label></li>
</ul>
</div>
</div>
</div>
<input id="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2_ClientState"
name="ctl03_ctl00_ctl00_Tabbed_ContentPlaceHolder_ContentPlaceHolder1_ContentPlaceHolder1_ctl00_ctl00_gvQuestions_ctl03_cblListItems2_ClientState"
type="hidden" autocomplete="off" value={"logEntries":[],"value":"292","text":"","enabled":true,"checkedIndices":[],"checkedItemsTextOverflows":false}>
</div>
</td>
</tr>
從圖像看,它看起來像是在工作。是否有例外被提出? –
問題是如何使用Selenium WebDriver處理這個菜單。 – Scott