2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Find the ids of drop down option using Selenium 2

I am converting my selenium 1 code to selenium 2 and can"t find any easy way to select a label in a drop down menu or get the selected value of a drop down. Do you know how to do that in Selenium 2? Please help me to find out.

Here is the code for you hope it will helpful.

Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));

To get the first selected value:
WebElement option = select.getFirstSelectedOption()

Answer is