Reputation: 68
how to select a value from drop down which comes when we click in the text box but does not comes with select syntax Using Chrome
Upvotes: 1
Views: 1068
Reputation: 365
public boolean selectDropdown(WebElement element, String itemName) {
try {
if (select != null) {
List<WebElement> options = select.findElements(/*use a proper selector*/);
for (WebElement option : options) {
String sListBoxOption = option.getText();
if (sSelectItem.equalsIgnoreCase(sListBoxOption)){
option.click();
return true;
}
}
}
return false;
} catch (Exception e) {
return false;
}
}
You can send the web Element and the Item in the drop-down which you have to select as parameters for this method.
Upvotes: 1