public String selectedValue ( ) { if ( isNotPresentSelect ( ) ) { return null ; } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; WebElement option = dropdown . getFirstSelectedOption ( ) ; return option . getAttribute ( VALUE ) ; }
Retrieves the selected value for the element . If the element isn t present or a select a null value will be returned .