如何从selenium向kendo multiselect发送多个值

时间:2014-04-25 15:48:29

标签: c# selenium kendo-ui selenium-webdriver

我想向Kendo Multiselect元素发送多个值。 每当我使用以下功能

((IJavaScriptExecutor)driver).ExecuteScript(String.Format("$('#   {0}').data('kendoMultiSelect').value({1});", "TagName", "Value"));

如果我尝试发送另一个值,我只能发送一次值,一旦删除,即每当我尝试发送新值时,旧的值会被删除。 Html代码: -

<div class="k-multiselect-wrap k-floatwrap" unselectable="on">
    <ul id="ProfileEditSharedModel_SelectedIndustrySectorIds_taglist" class="k-reset" unselectable="on" role="listbox">
        <li class="k-button" unselectable="on">
            <span unselectable="on">Sector 1</span>
            <span class="k-icon k-delete" unselectable="on">delete</span>
        </li>
    </ul>
    <input class="k-input" style="width: 25px;" accesskey="" role="listbox" aria-expanded="false" tabindex="0" aria-owns="ProfileEditSharedModel_SelectedIndustrySectorIds_taglist ProfileEditSharedModel_SelectedIndustrySectorIds_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false">
    <span class="k-icon k-loading k-loading-hidden"></span>
</div>
<select id="ProfileEditSharedModel_SelectedIndustrySectorIds" class="bigselect" name="ProfileEditSharedModel.SelectedIndustrySectorIds" multiple="multiple" data-val-required="*" data-val="true" data-placeholder="Select Sectors..." data-role="multiselect" style="display: none;" aria-disabled="false" aria-readonly="false">
    <option value="1">Sector 1</option>
    <option value="2">Sector 2</option>
    <option value="3">Sector 3</option>
</select>

1 个答案:

答案 0 :(得分:0)

您可以使用value方法发送数组

((IJavaScriptExecutor)driver).ExecuteScript(String.Format("$('#   {0}').data('kendoMultiSelect').value([1,2,3]);", "TagName", "Value"));