title: Selenium C# - How to verify dropdown list
body: <p>I need to verify drop down values using Selenium in C#. I have a set of values I want to test against with a IWebElements IList of this:</p>
  
  <pre><code>        IList&lt;IWebElement&gt; yearsDropdown = { "Select...", "Before 1996", "1996", "1997", "1998", "1999", "2000" }
  </code></pre>
  
  <p>I need to write a function that return all the values from a drop down (that has the same exact information) and then do an assert to confirm the match. Below is the code that i have written to print the values from drop down, but i need to assert those values with expected ones:</p>
  
  <pre><code>       IList&lt;IWebElement&gt; yearsDropdown = { "Select...", "Before 1996", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016" };
          string[] dropdownListArray = new string[23];
          IList&lt;IWebElement&gt; dropdownList = wd.FindElements(By.CssSelector("#Components_0__Entity_SourceInfo_Value_Entity_ModelYear"));
          foreach(IWebElement i in dropdownList)
          {
              dropdownListArray[] = i.Text;
          }
  
          for(int i = 0; i &lt; dropdownList.Count; i++)
          {
              Assert.AreEqual(yearsDropdown[i], dropdownList[i].Text);
          }
  </code></pre>
  
  <p>The thing is, when I tried this, it brought back the entire dropdown from the IWebElement IList dropdownList.  I need to have that IWebElement list to be broken down.</p>