At 11:14 AM 7/14/2005, Paul Rogers wrote:
I think the real problem here is that the clear_selection method ( or
whatever its called ) always checks to see if the page has reloaded.
This is so javascript onChange, onCLick events that cause a page reload
get executed correctly. ( think of a page with several select lists,
pick a country in the first, page reloads and populates the next with
state, etc )
In one of the previous controllers I had the same problem - the script
took ages to run cos of this continual checking. I added a optional
parameter to tell the controller to not bother with the wait if I knew
there was no javascript. So in this case we could have
Ie.select_list(;index,1).clear_selection( true )
Where there is a default that tells the method to wait, but it can also
not wait by setting the parameter to true.
This is pretty easy to add, and is much less work than implementing Bret
new select_list code.
-1 on adding a boolean value that indicates waits should be suppressed
1. There is no way that the person reading this code will be able to guess
what the true means. So it would undermine the clarity of our API.
2. The beauty of Watir has been that users don't have to decide whether to
code in waits or not. So even if we changed it to
clear_selection(:dont-wait), i would still be opposed.
3. I'm not convinced that this is really the source of Tuyet's problem. I
only see one call to wait in the method. We call wait after almost every
one of our commands. Tuyet says: "it takes over 20 seconds since my select
box has lots of items." This makes me think that it is iterating through
all the items that is causing the delay.
# This method clears the selected items in the select box
def clearSelection
assert_exists
highLight( :set)
wait = false
@o.each do |selectBoxItem|
if selectBoxItem.selected
selectBoxItem.selected = false
wait = true
end
end
@ieController.wait if wait
highLight( :clear)
end
Tuyet: how many items do you have in your list. We can use this information
to see if we can reproduce your problem.
On the assumption that Tuyet is using a single-select, i suggest that
clearSelection (and yes, this one hasn't been renamed yet to
clear_selection) only iterate through the list with multi-selects. Or that
we at least see if this would solve Tuyet's problem. This solution has the
added benefit of not complicating our API.
Bret
_____________________
Bret Pettichord
www.pettichord.com
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general