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](https://github.com/sturman.png)
Contributed the initial Java code for this tip.
![Mike Millgate](https://github.com/trabulmonkee.png)
Contributed the Python code for this tip.
![Isaul Vargas](https://github.com/isaulv.png)
Python code review
![Peter Bittner](https://github.com/bittner.png)
Python code review
![Jonathan Taylor](https://github.com/jtay2380.png)
Contributed the initial C# code for this tip.
![Andrei Solntsev](https://github.com/asolntsev.png)
Contributed the Selenide code for this tip.
Authors
![Dave Piacente](https://github.com/tourdedave.png)
Original creator of Elemental Selenium
![Diego Molina](https://github.com/diemol.png)
Current maintainer of Elemental Selenium