title: How to select an item from a dropdown list using Selenium WebDriver with java?
body: <p>How can I select an item from a drop down list like gender (eg male, female) using Selenium WebDriver with Java?</p>
  
  <p>I have tried this</p>
  
  <pre><code>WebElement select = driver.findElement(By.id("gender"));
  List&lt;WebElement&gt; options = select.findElements(By.tagName("Male"));
  for (WebElement option : options) {
      if("Germany".equals(option.getText()))
          option.click();   
  }
  </code></pre>
  
  <p>My above code didn't work.</p>