When using the selenium web driver, we are trying to retrieve a set of option values such as Last 30 days, Last 60 days, etc.
Attempts have been made to locate these elements using a CSS selector.
var timeperiodcss = "span.k-widget.k-dropdown.k-header select#selectDefaultTimePeriod option";
var elements = element.FindElements(By.CssSelector(timeperiodcss));
if (elements.Count >= 1)
break;
However, each time elements.count returns 0. We are unable to access these elements.
The HTML content for these cases is as follows:
<span class="k-widget k-dropdown k-header" style="width: 150px;" title="" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="selectDefaultTimePeriod_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="0936dfb5-4f8c-4dd4-826f-f802b6a719ff">
<span class="k-dropdown-wrap k-state-default" unselectable="on">
<select id="selectDefaultTimePeriod" style="width: 150px; display: none;" data-bind="kendoDropDownList:timePeriodOptions" data-role="dropdownlist">
<option value="">Select time period</option>
<option value="Last 30 days">Last 30 days</option>
<option value="Last 60 days">Last 60 days</option>
<option value="Last 90 days" selected="selected">Last 90 days</option>
<option value="Last month">Last month</option>
<option value="Last quarter">Last quarter</option>
<option value="Last 6 months">Last 6 months</option>
<option value="Last 12 months">Last 12 months</option>
<option value="Last 365 days">Last 365 days</option>
<option value="Full year 2016">Full year 2016</option>
</select>
</span>
If you know of any other method to retrieve these elements, please do let me know.