java如何在自动测试中从Kendo UI MVVM下拉列表中选择值?
有人能帮我用SeleniumJava从KendoUIMVVM下拉列表中选择一个值吗
<input class="k-input fieldFullWidth" autocomplete="off" style="width: 100%;" title="" role="combobox" aria-expanded="false" tabindex="0" aria-disabled="false" aria-autocomplete="both" aria-owns="ddStore_listbox" type="text">
<input id="ddStore" class="fieldFullWidth" data-role="combobox" style="display: none;" aria-disabled="false" data-bind="value: selectedAsset.StoreID, comboboxText: selectedAsset.StoreName">
我尝试使用JavascriptExecutor。但是,它给了我组织。openqa。硒。WebDriverException:未知错误:无法设置null错误的属性“值”
jse.executeScript("document.getElementById('ddstore').value = '1';");
谢谢
# 1 楼答案
使用
ExplicitWait
等待<input>
标记元素的可见性,然后将下拉值作为输入发送`
另一种替代方法是使用
JavascriptExecuter
,因为您的标记包含属性style="display: none;"
,所以可能会更改元素的不可见性# 2 楼答案
您可以尝试以下代码来选择下拉值: