我需要从下拉列表中选择值ABCD,EFGH和IJKL。
我尝试了下面的代码,但是在单击下拉列表中所有选项都存在的文本框后,它卡住了。
我认为这是因为在HTML网页中,相同的对话框以相同的名称显示,并且下拉列表中的选项不同,因此它卡住并引起混乱。我认为这样对吗?
下拉菜单的HTML代码:
<span class="k-widget" style="width: 200px;" title=""
class="k-widget k-dropdown k-header required k-invalid"
unselectable="on" role="listbox" aria-haspopup="true"
aria-expanded="false" tabindex="0"
aria-owns="numberTypeDropDown_listbox"
aria-disabled="false" aria-busy="false">
<span class="k-dropdown-wrap k-state-default" unselectable="on" >
<span class="k-input ng-scope" unselectable="on"></span>
<span class="k-select" unselectable="on" aria-label="select">
<span class="k-icon k-i-arrow-60-down"></span>
</span>
</span>
<select id="numberTypeDropDown" class="required k-invalid"
name="ProductRelatedNumberType"
kendo-drop-down-list="productRelatedNumberTypeDropDown"
k-data-source="RelatedNumberTypesSource" k-data-value-field="'Value'"
k-data-text-field="'Text'" k-auto-bind="false"
k-value-primitive="true" k-change="RelatedNumberTypeChanged"
validationmessage="Related Number Type is required"
k-ng-model="RelatedNumberType" style="width: 200px; display: none;"
required="" data-role="dropdownlist"
aria-invalid="true">
<option value="ABCD">ABCD</option>
<option value="EFGH">EFGH</option>
<option value="IJKL">IJKL</option>
<option value="MNOP">MNOP</option>
<option value="QRST">QRST</option>
</select>
我尝试过的硒代码:
List<WebElement> dropdown=driver.findElements(By.xpath("//ul[@id='numberTypeDropDown_listbox']"));
List<WebElement> dropdown3= dropdown.get(0).findElements(By.tagName("li"));