Watir-Webdriver working with huge select lists


I’m having trouble understanding the most efficient way to work with a
select list. I can work alright with smaller ones, but there’s a list I
have to use with over 14 thousand entries, and the value is different
from the content. When I try to use webdriver to select an item, it will
use the content.

I need to find a way to select by value, find the entry with a matching
value and select its content, or pull the entire list into an array so I
can search it and find the content to go with the value.

For illustrative purposes, with the below I might have only “Java”, but
I wouldn’t be able to use the select list without setting it to “Java

Java content Ruby Content C# con tent Clojure conttent Python thingy

Now, since the list itself is over 14k items (oh god, why?!) even the
most efficient ways I’ve tried using Webdriver or even executing
JavaScript take a long time, and if I do it all in one JavaScript
command it times out.

This is the best I’ve been able to come up with so far:

len = b.execute_script(%Q^ return
list = []
(0…len).each {|num|
list.push(b.execute_script(%Q^ return
puts num

This doesn’t trigger the JavaScript timeout, but takes 3 minutes.
Am I missing some obvious way to select this by its value or extract
everything for comparison?


I just realised I’m an idiot… it took laying out my problem like that
for me to realise that all I need to do is use JavaScript to select the

Apparently “select_value” is a method in webdriver. Oops.