vendredi 6 novembre 2015

How to Traverse Non-Select Dropdown using selenium?

I am trying to get all the options available in a KendoUI dropdown which uses 'k-dropdown' as its control rather than a 'select'. Therefore, I cannot use something like (since there is no select element):

    public void ChooseOrderType(string type)
    {
        var mySelect = new SelectElement(TypeDropDownLocator);
        var options = mySelect.Options;
        foreach (var option in options) {
            if (option.Text.Equals(type))
                option.Click();
        }

    }

HTML:

<span class="k-widget k-dropdown k-header" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="orderStatus_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="orderStatus_option_selected">
    <span unselectable="on" class="k-dropdown-wrap k-state-default">
        <span unselectable="on" class="k-input">All orders</span>
        <span unselectable="on" class="k-select">
            <span unselectable="on" class="k-icon k-i-arrow-s">select</span>
        </span>
    </span>
    <input id="orderStatus" name="orderStatus" type="text" data-role="dropdownlist" style="display: none;">
    </span>

Is there any way to traverse this manually to get all the options?

Aucun commentaire:

Enregistrer un commentaire