title: WebBrowser control HTMLDocument automate selecting option drop-down
body: <p>I'm trying to automate in a WinForm using a WebBrowser control to navigate and pull report info from a website. You can enter values in textboxes and invoke the click events for buttons and links, but I have not figured out how select a option drop-down .... in a automated way. Anybody recommend how to select a item from a drop-down, given this html example:</p>
  
  <pre><code>&lt;SELECT id="term_id" size="1" name="p_term_in"&gt;&lt;option value=""&gt;Select Another Term&lt;option value="201050"&gt;Summer 2010&lt;option value="201010"&gt;Spring 2010&lt;option value="200980"&gt;Fall 2009&lt;/SELECT&gt;
  </code></pre>
  
  <p>For others that can learn from entering values to textboxes and invoking click events here's how you do it:</p>
  
  <pre><code>webBrowser1.Document.GetElementById("&lt;HTML ELEMENT NAME&gt;").SetAttribute("value", "THE NAME");
  </code></pre>
  
  <p>Invoke button or hyperlink click:</p>
  
  <pre><code>webBrowser1.Document.GetElementById("&lt;BUTTON&gt;").InvokeMember("click");
  </code></pre>
  
  <p>So I've solved entering values and invoking click, but I have not solved selecting a drop-down value.</p>