I had been having some issues getting a dropdown to select a value using the Watir Webdriver and I wanted to briefly write up what I was doing verses what I should have been doing.

In my specific case I wanted to use Watir to drive a date selection using the jQuery datepicker so I inspected the elements and found a class I could latch onto to grab the year dropdown.

select(:class, 'ui-datepicker-year').select('2006')

I thought this would work, but it was telling me that instead of a symbol it was expecting an array. I am guessing this is because out of context it doesn't know if I mean a select element or I want to select something.

The fix was to chain my select with a parent element, like so:

div(:class, 'ui-datepicker-title').select(:class, 'ui-datepicker-year').select('2006')

Now Watir knows that .select means a select box and not to select something.

If you are interested in finding out more I have written up a short blog post about controlling the jQuery datepicker in Watir.