In this tutorial, we are going to study the handling of dropdowns in Selenium WebDriver. For practice, you can check the dummy page having a dropdown element.

Content
Select in Selenium WebDriver
The ‘Select’ class in Selenium WebDriver is used for selecting and deselecting the option in a dropdown. The objects of Select type can be initialized by passing the dropdown webElement as parameter to its constructor.
WebElement testDropDown = driver.findElement(By.id("testingDropdown"));
Select dropdown = new Select(testDropDown);
Selecting options from dropdown
There are three ways of selecting options from dropdown-
1. selectByIndex – To select an option based on its index, beginning with 0.
dropdown.selectByIndex(3);
2. selectByValue – To select an option based on its ‘value’ attribute.
dropdown.selectByValue("Database");
3. selectByVisibleText – To select an option based on the text over the option.
dropdown.selectByVisibleText("Database Testing");
Different utility methods in the Select class
- deselectAll() – To deselect all the selected options.
- deselectByIndex(int index) – To deselect the option based on its index.
- deselectByValue(String valueAttribute) – To deselect the option its ‘value’ attribute.
- deselectByVisibleText(String text) – To deselect the option based on the text over the option.
- getOptions() – To return list of all the options(List<WebElement>).
- getAllSelectedOptions() – To return the list of all the selected options(List<WebElement>).
- getFirstSelectedOption() – To return the selected option or the first selected option in case of dropdowns allowing multi-select.
- isMultiple() – To return a boolean value, checking if the dropdown allows multiple option select or not.
That’s all we have in this post. If you have any questions please comment below. Check out the complete tutorial below.

Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals. You can connect with him on LinkedIn.
driver.get(“https://artoftesting.com/samplesiteforselenium”);
WebElement testDropDown = driver.findElement(By.id(“testingDropdown”));
Select dropdown = new Select(testDropDown);
//dropdown.selectByIndex(2);
dropdown.selectByVisibleText(“Manual Testing”);
Here is the code I tried. I could get to open the website but not the dropdownlist selection. could you guide me as of where I went wrong.
The code is perfectly fine. Maybe you need to use implicit wait.
Is there any other way of handling drop down? Other than select ?
You can use JavascriptExecutor.