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
Contributed the initial Java code for this tip.
Contributed the Python code for this tip.
Python code review
Python code review
Contributed the initial C# code for this tip.
Contributed the Selenide code for this tip.
Authors
Original creator of Elemental Selenium
Current maintainer of Elemental Selenium