title: How To select a Value From Drop-Down using Selenium?
body: <p>Given Below is a Piece of Code which denotes a Drop-Down.
  I need to Select <strong>Date</strong> value in this Drop-down denoted By <code>&lt;option value="1" label="Date"&gt;Date&lt;/option&gt;</code> </p>
  
  <pre><code>&lt;select id="type" class="text-input ng-pristine ng-valid ng-scope ng-touched" ng-style="cssStyle" name="type" ng-if="!options.hidePlaceholder" ng-model="result.type" qmx-observe-value="text" ng-disabled="options.readonly" ng-options="obj.value as obj.text group by obj.groupby for obj in selectData" style="font-size: 13px; opacity: 1; width: 100%;"&gt;
      &lt;option class="ng-binding" value=""&gt;----&lt;/option&gt;
      &lt;option value="0" selected="selected" label="Text"&gt;Text&lt;/option&gt;
      &lt;option value="1" label="Date"&gt;Date&lt;/option&gt;
      &lt;option value="2" label="Numeric"&gt;Numeric&lt;/option&gt;
      &lt;option value="3" label="Switch"&gt;Switch&lt;/option&gt;
      &lt;option value="4" label="Map Location Marker"&gt;Map Location Marker&lt;/option&gt;
      &lt;option value="5" label="Picker"&gt;Picker&lt;/option&gt;
      &lt;option value="6" label="List"&gt;List&lt;/option&gt;
      &lt;/select&gt;
  </code></pre>
  
  <p>Following Methods didn't work.
  <br>1.) selecting this value using <em>Select</em> by importing <strong>org.openqa.selenium.support.ui.Select</strong></p>
  
  <pre><code>Select elm = new Select(driver.findElement(By.xpath(".//*[@id='type']/option[3]")));
    elm.selectByVisibleText("Date");
  </code></pre>
  
  <p>Console shows: </p>
  
  <blockquote>
    <p>Element should have been "select" but was "option"</p>
  </blockquote>
  
  <p><br>2.) Clicking on the Drop-Down first to display option to be selected and then clicking on the option.</p>
  
  <pre><code>driver.findElement(By.xpath(".//*[@id='type']")).click();
  driver.findElement(By.xpath(".//*[@id='type']/option[3]")).click();
  </code></pre>
  
  <p>Console shows: </p>
  
  <blockquote>
    <p>DEBUG Element is missing an accessible name: id: type, tagName:
    SELECT, className: text-input ng-pristine ng-untouched ng-valid
    ng-scope</p>
  </blockquote>
  
  <p><br> 3.) Using JavascriptExecutor to get the click.</p>
  
  <pre><code>driver.findElement(By.xpath(".//*[@id='type']")).click();    
  ((JavascriptExecutor)driver).executeScript("arguments[0].click();", driver.findElement(By.xpath(".//*[@id='type']/option[3]")));
  </code></pre>
  
  <p>Console shows:</p>
  
  <blockquote>
    <p>DEBUG    Element is missing an accessible name: id: type, tagName:
    SELECT, className: text-input ng-pristine ng-untouched ng-valid
    ng-scope</p>
  </blockquote>
  
  <p><br>4.) Using Mouse-Over on Option to be selected in Drop-down and then performing click on it.</p>
  
  <pre><code>driver.findElement(By.xpath(".//*[@id='type']")).click();    
  WebElement subdrop = driver.findElement(By.xpath(".//*[@id='type']/option[3]"));
          Actions action = new Actions(drive);
          action.moveToElement(subdrop).perform();
          Custom.Twait();
          action.click(subdrop).perform();
  </code></pre>
  
  <p>Console shows: </p>
  
  <blockquote>
    <p>Exception in thread "main"
    org.openqa.selenium.UnsupportedCommandException: POST
    /session/a37a745a-e40c-45a9-9760-8e01b451a017/moveto did not match a
    known command (WARNING: The server did not provide any stacktrace
    information)</p>
  </blockquote>
  
  <p><em>I have also added Wait in Between where i'm using this code. Here for simplicity i did not include it.</em></p>
  
  <p>Need Help.</p>