title: Using Selenium for selecting an option on a select with optgroup
body: <p>I'm trying to select a value in a select element. I'm using Selenium RC (Java) to run the test cases. I understand that the code for selecting a value is given by:</p>
  
  <pre><code>selenium.select("locator", "value=REQUIRED VALUE")
  </code></pre>
  
  <p>I'm unable to select the desired value with the above code. I think it might be something to do with optgroup in the select source code. I do not get any exceptions, the command executes fine but looking at the page the required value is not selected.
  Also, I cant use ids (instead of value) because there arent any. Here is the source code of the selector:</p>
  
  <pre><code>&lt;select&gt;
     &lt;optgroup label="Group1"&gt;
        &lt;option value="13"&gt;some value1&lt;/option&gt;
        &lt;option value="25"&gt;some value2&lt;/option&gt;
     &lt;/optgroup&gt;
     &lt;optgroup label="Group2"&gt;
        &lt;option value="18"&gt;REQUIRED VALUE&lt;/option&gt;
        &lt;option value="34"&gt;some value3&lt;/option&gt;
        ...
        ...
     &lt;/optgroup&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Is there any way to select the required value using Selenium?</p>
  
  <p>It would be great if we could avoid the option values (such as "18", "34" etc) because these numbers change later as the values change. For example, "REQUIRED VALUE" has a value -18 but if I were to delete this item and add it again its value would be different. Basically this drop-down box is dynamic.</p>