Skip to main content

How to Select from a Dropdown List

The Problem

Some common use cases for selecting from a dropdown list might be selecting sizes or styles from a dropdown menu while online shopping, or selecting your method of payment. And, while selecting from a dropdown list might seem straightforward -- just grab the list by its element and select an item within it, based on the text you want -- there's a bit more skill to it.

Let's take a look at a couple of different approaches.

Expected Behavior

  • Open the browser
  • Visit the example application
  • Find the dropdown list
  • Select the specified item from the dropdown list
  • Assert that the selected option is what you expect
  • Close the browser

Outro

Hopefully this tip will help you breeze through selecting items from a dropdown list.

Happy Testing!

Special Thanks

Roman Isko
Contributed the initial Java code for this tip.
Mike Millgate
Contributed the Python code for this tip.
Isaul Vargas
Python code review
Peter Bittner
Python code review
Jonathan Taylor
Contributed the initial C# code for this tip.
Andrei Solntsev
Contributed the Selenide code for this tip.

Authors

Dave Piacente
Original creator of Elemental Selenium
Diego Molina
Current maintainer of Elemental Selenium