The class Selenium Select has 3 methods of different option selection:
Now,
In latest Selenium version 3.x or 4.x, Select class can be used to select an option from dropdown.
For example: There is a flavour dropdown where it require to select a flavour which contain name as Vanilla.
WebElement flavour = driver.findElement(By.id("attribute178"));
Select select = new Select(flavour);
String expectedFlavourName = "Vanilla";
List allFlavourList = select.getOptions();
for (WebElement option : allFlavourList) {
String currentFlavourName = option.getText();
if (currentFlavourName.contains(expectedFlavourName)) {
select.selectByVisibleText(currentFlavourName);
}
}