Also need to not select the empty option; here's using Watir methods:


browser.select(id: 'optionkey').options.find {|el| 
!el.attribute_value('disabled') && el.value != ''}


or just:


browser.options.find {|el| !el.attribute_value('disabled') && el.value != ''}




On Friday, November 7, 2014 10:32:47 AM UTC-6, Leonardo Elias 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.

Reply via email to