Dropdown and lists elements are manipulated by means of the Select class. This class provides methods and properties to interact with dropdown and lists that are created with the <select> element:
- void deselectAll(): Clears all selected entries
- void deselectByIndex(int index): Clears the option at the given index
- void deselectByValue(java.lang.String value): Clears all options that match a given value
- void deselectByVisibleText(java.lang.String value): Clears all options that display text matching a given value
- java.util.List<WebElement> getAllSelectedOptions(): Gets all selected options of the list
- WebElement getFirstSelectedOption(): Gets the first selected option of the list
- java.util.List<WebElement> getOptions(): Gets all options of the list
- boolean isMultiple(): Indicates if the list supports multiple options at the same time or not
- void selectByIndex(int index): Selects the option at the given index
- void selectByValue(java.lang.String value): Selects all options that match a given value
- void selectByVisibleText(java.lang.String text): Selects all options that display text matching a given text
Up-to-date documentation of the Select class can be found at https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html.