If you don't mind using xpath you can select by checking for attribute 'disabled' does not exist:
//select[@name='optionkey']/option[not(@disabled='disabled')][1] This way it will only select options that aren't disabled, and by adding the [1] at the end, it selects the first available non-disabled option. On Fri, Nov 7, 2014 at 8:32 AM, Leonardo Elias <[email protected]> wrote: > I have an HTML like this > > <select name="optionkey" id="optionkey"> > <option value="" class=""></option> > <option value="0" disabled="disabled">Option 1</option> > <option value="1">Option 2/option> > <option value="2">Option 3</option> > <option value="3" disabled="disabled">Option 4</option> > </select> > > Sometimes the first option can be enabled but, sometimes like in this > example, the first option could be disabled. The disabled attribute will be > present only for the inactive options > > I need to select the first enabled option in the dropdown, any ideas? > > Thanks > > -- > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > [email protected] > http://groups.google.com/group/watir-general > [email protected] > > --- > You received this message because you are subscribed to the Google Groups > "Watir General" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Derek Wrobel 425-243-3355 -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
