title: How to select webelement from dropdown menu using webdriver
body: <p>I am trying to select a webelement from a dropdown but not able to do so. 
  The webelement which i am trying to select from the drop down is 
  <strong>Edit/ViewResume</strong></p>
  
  <hr>
  
  <h2>1st Try</h2>
  
  <p>In my first attempt i tried to select the webelement by using Action and Select class methods. Here to select the element from the dropdown i tried selectByValue(value), selectByIndex(1) and selectByVisibleText(text) but none of them worked and i got <strong>org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "a"</strong> this exception.</p>
  
  <pre><code>  Webelement wb = driver.findElement(By.xpath("//div[@class='ns_menu_item_wrap ns_lt active']/a"));
    Actions mouse = new Actions(driver);
    mouse.moveToElement(wb).perform();
    Select sel = new Select(wb);
    sel.selectByIndex(1);
  </code></pre>
  
  <hr>
  
  <h2>2nd Try</h2>
  
  <p>Here i tried to select the element by using Action class build(), click() and perform() methods but nothing happened i.e, i am still not able to select the webelement from the dropdown. For this code i am not getting any exception.</p>
  
  <pre><code>  Webelement wb = driver.findElement(By.xpath("//div[@class='ns_menu_item_wrap ns_lt active']/a"));
    Actions mouse = new Actions(driver);
    mouse.moveToElement(wb).click();
    driver.manage().timeouts().implicitlyWait(10 , TimeUnit.SECONDS);
    wb=driver.findElement(By.xpath("//a[contains(@href,'http://my.monsterindia.com/view_resume.html?mode=edit')]"));
    mouse.moveToElement(wb).click();
    driver.manage().timeouts().implicitlyWait(10 , TimeUnit.SECONDS);
    mouse.build();
    Thread.sleep(4000);
    mouse.perform(); 
  </code></pre>
  
  <hr>
  
  <h2>HTML Snippet of dropdown option</h2>
  
  <pre><code>&lt;div class="ns_menu_item_wrap ns_lt active"&gt;
  &lt;a class="ns_menu_item" href="http://my.monsterindia.com/my_monster.html"&gt;My Monster&lt;/a&gt;
  &lt;div class="ns_dropdown" style="display: none; left: -2px;"&gt;
  &lt;div class="ns_dropdown_inner"&gt;
  &lt;div class="ns_dd_link_wrap"&gt;
  &lt;a class="ns_dd_link" href="http://my.monsterindia.com/view_resume.html?mode=edit"&gt;Edit/View Resume&lt;/a&gt;
  &lt;a class="ns_dd_link" href="http://my.monsterindia.com/applications.html"&gt;My Applications&lt;/a&gt;
  &lt;a class="ns_dd_link" href="http://my.monsterindia.com/manageagents.html"&gt;Job Agent&lt;/a&gt;
  &lt;a class="ns_dd_link" href="http://my.monsterindia.com/confidentiality.html"&gt;Privacy Plus&lt;/a&gt;
  &lt;a class="ns_dd_link" href="http://my.monsterindia.com/newsletter.html"&gt;Subscriptions&lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="ns_dd_othertxt"&gt;
  &lt;div class="ns_clr"/&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>