#Using the Select Utility Class The big secret to working with dropdowns is that you don't want to work with them as WebElements, but instead create a Select element for them. The Select class ([java][1] and [python][2] documentation) includes utility methods that allow you to perform common tasks. We will be working with the following html: <select id="mySelectID"> <option value="Value">Option</option> <option value="NotValue">Not Option</option> </select> ##Select by option name Java: WebElement mySelectElm = driver.findElement(By.id("mySelectID")); Select mySelect= new Select(mySelectElm); selMySelect.selectByVisibleText("Option"); Python: mySelect = Select(driver.find_element_by_id("mySelectID")) mySelect.select_by_visible_text("Option") C#: var mySelectElm = driver.FindElement(By.Id("mySelectID")); var mySelect = new SelectElement(mySelectElm); selectElement.SelectByText("Option"); ##Select by option value Java: WebElement mySelectElm = driver.findElement(By.id("mySelectID")); Select mySelect= new Select(mySelectElm); selMySelect.selectByValue("Value"); Python: mySelect = Select(driver.find_element_by_id("mySelectID")) mySelect.select_by_value("Value") C#: var mySelectElm = driver.FindElement(By.Id("mySelectID")); var mySelect = new SelectElement(mySelectElm); selectElement.SelectByValue("Value"); ##Select by index Java: WebElement mySelectElm = driver.findElement(By.id("mySelectID")); Select mySelect= new Select(mySelectElm); selMySelect.selectByIndex(0); Python: mySelect = Select(driver.find_element_by_id("mySelectID")) mySelect.select_by_index(0) C#: var mySelectElm = driver.FindElement(By.Id("mySelectID")); var mySelect = new SelectElement(mySelectElm); selectElement.SelectByIndex(0); ##Get the selected option Java: WebElement mySelectElm = driver.findElement(By.id("mySelectID")); Select mySelect= new Select(mySelectElm); WebElement option = mySelect.getFirstSelectedOption(); System.out.println(option.getText()); //prints "Option" Python: mySelect = Select(driver.find_element_by_id("mySelectID")) option = mySelect.first_selected_option print option.text #prints "Option" C#: var mySelectElm = driver.FindElement(By.Id("mySelectID")); var mySelect = new SelectElement(mySelectElm); var option = mySelect.SelectedOption; Console.write(option.Text); //prints "Option" ##Get the list of options Java: WebElement mySelectElm = driver.findElement(By.id("mySelectID")); Select mySelect= new Select(mySelectElm); List<WebElement> options = mySelect.getOptions(); for (WebElement option : options) { System.out.println(option.getText()); //Prints "Option", followed by "Not Option" } Python: mySelect = Select(driver.find_element_by_id("mySelectID")) print [o.text for o in mySelect.options] #Prints "Option", followed by "Not Option" C#: var mySelectElm = driver.FindElement(By.Id("mySelectID")); var mySelect = new SelectElement(mySelectElm); var options = mySelect.SelectedOptions; foreach(var option in options) { Console.write(option.Text); //Prints "Option", followed by "Not Option" } [1]: http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/ui/Select.html [2]: http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_support/selenium.webdriver.support.select.html