Hi,
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
content".
<select id="entry_1" name="entry.1.single">
<option value="Java">Java content</option>
<option value="Ruby">Ruby Content</option>
<option value="C#">C# con tent</option>
<option value="Clojure">Clojure conttent</option>
<option value="Python">Python thingy</option>
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
document.getElementsByName('item_type')[0].length^)
list = []
(0...len).each {|num|
list.push(b.execute_script(%Q^ return
document.getElementsByName('item_type')[0].options[#{num}].text^))
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?
Thanks
···
--
Posted via http://www.ruby-forum.com/.