How to check the drop down list item is selected

public static WebElement drpdwn_selectMonth() throws Exception{


WebElement monthSelector = driver.findElement("monthID"));;

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

monthSelector = driver.findElement(By.xpath("//*[@id='monthID']/option[2]"));;

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}catch (Exception e){



return element;


1. how to do a Boolean check there is a value under drop down list is selected?

2. how to print the value selected in drop down list

Add Comment
  • 1 Answer(s)
    Best answer

    You have to use the Select class to work on Drop Down elements.
    However there is no specific way to to get a Boolean value for element selected in drop-down or not.

    WebElement select = driver.findElement(By.tagName("select"));
    WebElement option = select.getFirstSelectedOption();
    //OR you can use "getAllSelectedOptions()" to return the list of elements selected.

    Supporter Answered on January 27, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.