This article briefly explains how to, or at lease how I interact with dropdown menus in C#. Generally speaking I try to pass through the identifier and the value to select to a helper method which carries out the task.
Lets have a look at a typical step definition, first we’re waiting for the element to appear on screen and then selecting the option by value.
public void WhenISelectTheOrganisation(string orgName)
So lets look at SelectFromDropDownByClass:
We’re creating a new instance of Webdrivers’ SelectElement and passing through the class name and text of the item in the dropdown, keeping the identifier variable ensures we can reuse the same method elsewhere in the solution, you can interact and select items in other ways from dropdowns and also use other identifiers as necessary such as Id, CssSeleector and XPath.