I am trying to select the item from dropdown in selenium webdriver using java, but not able to select it. Its showing element not found exception and in html tag drop down is hidden. html code are:
div style="width:49%">
<select id="menu_id" class="select-block" onchange="showSubmenu(this.value);" style="display: none;">
<option value="">Select Category</option>
<option value="1">CASINO</option>
<option value="2">ACCOMMODATIONS</option>
<option value="3">DINING</option>
<option value="4">ENTERTAINMENT & EVENTS</option>
<option value="5">SPA & FITNESS</option>
<option value="8">GOLF & SPORTS</option>
<option value="9">MEETING, WEDDINGS & GROUPS</option>
<option value="10">PACKAGES</option>
<option value="11">NIGHTLIFE & LOUNGES</option>
</select>
<div class="btn-group select select-block">
<i class="dropdown-arrow dropdown-arrow-inverse"/>
<button id="menu_id" class="btn dropdown-toggle clearfix btn-primary" data-toggle="dropdown">
<span class="filter-option pull-left">Select Category</span>
<span class="caret"/>
</button>
<ul class="dropdown-menu dropdown-inverse" role="menu">
<li class="selected" rel="0">
<a class="" href="#" tabindex="-1">
</li>
<li rel="1">
<li rel="2">
<li rel="3">
<li rel="4">
<li rel="5">
<li rel="6">
<li rel="7">
<li rel="8">
<li rel="9">
</ul>
</div>
</div>
These is the script I'm using:
submenu=topbanner.getSelectSubMenuLink();
Select se1=new Select(submenu);
se1.selectByIndex(1)
In the above code I am using object repository concept and path I have written under findby keys.
@FindBy(xpath="//select[@id='menu_id']");
private WebElement selSubMenuLink;
public WebElement getSelectSubMenuLink()
{
return selectSubMenuLink;
}