The Below code searches for an item in the drop down and selects it
public void Dropdown(String
eleproperty, String value) {
WebElement element = driver.findElement(By.id(eleproperty));
if
(element.isEnabled()) {
WebElement dropdown = driver.findElement(By.id(eleproperty));
Select select = new
Select(dropdown);
String str =
dropdown.getText();
List<WebElement> options
= select.getOptions();
for (WebElement we
: options) {
if
(we.getText().equals(value)) {
we.click();
break;
}
}
} else {
System.out.println("Object
is disabled");
}
}
Contributed by: Ch. Suma
Contributed by: Ch. Suma