public boolean isValueSelectedInDropDown ( final By by , final String value ) { WebElement element = driver . findElement ( by ) ; StringBuilder builder = new StringBuilder ( ".//option[@value = " ) ; builder . append ( escapeQuotes ( value ) ) ; builder . append ( "]" ) ; List < WebElement > options = element . findElements ( By . xpath ( builder . toString ( ) ) ) ; for ( WebElement opt : options ) { if ( opt . isSelected ( ) ) { return true ; } } return false ; }
Checks if a value is selected in a drop down list .