title: How to get selected option using Selenium WebDriver with Java
body: <p>I want to <strong>get the selected label</strong> or value of a <strong>drop down</strong> using Selenium WebDriver and then <strong>print</strong> it on the <strong>console</strong>.</p>
  
  <p>I am able to select any value from the drop down, but I am not able to retrieve the selected value and print it:</p>
  
  <pre><code>Select select = new 
  Select(driver.findElement(By.id("MyDropDown"))).selectByVisibleText(data[11].substring(1 , data[11].length()-1));
  WebElement option = select.getFirstSelectedOption();
  </code></pre>
  
  <p>But all my efforts were in vain. How do I get the selected option?</p>