Select class in WebDriver is used for selecting and deselecting options in a dropdown.
The objects of Select type can be initialized by passing the dropdown webElement as a parameter to its constructor.
WebElement testDrop = driver.findElement(By.id("testingDropdown"));
Select dropdown = new Select(testDrop);
WebDriver offers three ways to select from a dropdown:
selectByIndex: Selection based on index starting from 0
dropdown.selectByIndex(5);
selectByValue: Selection based on value
dropdown.selectByValue(“Books”);
selectByVisibleText: Selection of option that displays text matching the given argument
dropdown.selectByVisibleText(“The Alchemist”);