I am very new to Selenium and I'm stuck here:
I want to get the selected label or value of a drop down using Selenium WebDriver and then print it on the console.
I'm just able to select any value from the drop-down but not able to retrieve the selected value and print it.
Select select = new
Select(driver.findElement(By.id("MyDropDown"))).selectByVisibleText(data.substring(1 , data.length()-1));
WebElement option = select.getFirstSelectedOption();
But all my efforts are going in vain. Any help would be appreciated.