26
Jun

select drop down value by visible text / index value

public static void selectDropDownByVisibleText(WebElement webElement, String visibleText) {
Select dropdown = new Select(webElement);
if(visibleText ==null ||visibleText.isEmpty()){
return;
}
dropdown.selectByVisibleText(visibleText);
System.out.println(“Value selected:{} “, visibleText);

}

=======================================================

public static void selectDropDownByIndex(MCWebElement mcWebElement, int index) {
Select dropdown = new Select(mcWebElement.getFluent().getWebElement());
dropdown.selectByIndex(index);
}