title: Selenium 2 + WebDriver + .NET: Can't retrieve text of select's options if select is "display:none;"
body: <p>I have this select on a page:</p>
  
  <pre><code>&lt;select multiple="" class="recipientsList" name="Recipients[]" id="To" style="display: none;"&gt;
      &lt;option value="User-6" class=""&gt;Coordinator, Test&lt;/option&gt;
      &lt;option value="Course-4" class=""&gt;New Course 1&lt;/option&gt;
      &lt;option value="UserType-6" class=""&gt;Coordinators&lt;/option&gt;
      &lt;option value="UserTypeInCourse-4-6" class=""&gt;New Course 1 Coordinator&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>And I'm running this test:</p>
  
  <pre><code>public IWebDriver WebDriver
  {
      get 
      { 
          // gets the current WebDriver instance, set up elsewhere at the beginning
          // of the fixture
          return ScenarioContext.Current.WebDriver(); 
      }
  }
  
  public void SelectTest()
  {
      // code to navigate to proper page
  
      var options = WebDriver.FindElements(By.CssSelector("select.recipientsList option"));
  
      Assert.That(options, Is.Not.Empty, "No options found.");
      Assert.That(!options.Any(option =&gt; string.IsNullOrEmpty(option.Text)), "Some or all options have blank text.");
      // Actual useful assert
  }
  </code></pre>
  
  <p>The second assert is failing because all of the elements in the <code>options</code> collection has empty string as their Text objects. It works if I remove the JavaScript on the page that adds the <code>display:none;</code> style. This is not a permanent solution though, as this select needs to be hidden, as it is extended by <a href="http://www.emposha.com/javascript/fcbkcomplete.html" rel="nofollow">FCBKcomplete</a>.</p>
  
  <p><strong>How do I get the text of hidden select options with Selenium 2/WebDriver in .NET?</strong></p>