In the meantime Ben, Ruby is very cool in that you can extend it
whenever you want. So if you still need to do this while waiting for
the feature to be included in Watir, you can just extend it yourself by
adding this code to your program:
class Watir::SelectList
def getSelectedValues
assert_exists
returnArray = []
@o.each do |thisItem|
if thisItem.selected
returnArray << thisItem.value
end
end
return returnArray
end
end
(The keyword 'return' is not strictly necessary.)
Use it exactly as you would use getSelectedItems:
ie.select_list(:name, "thename").getSelectedValues[0]
Hope that helps.
Lonny Eachus
===========
Feature Requests item #5289, was opened at 2006-08-03 12:52
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=490&aid=5289&group_id=104
Category: General
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Ben Mills (benmills)
Assigned to: Nobody (None)
Summary: Asserting that a particular option is selected in a drop down
Initial Comment:
I have a situation where I'm using the querystring of the URL to preselect an option in a drop down. I want to assert the correct option is selected. It seems like the best way for me to get the selected option is:
ie.select_list(:name, "thename").getSelectedItems()[0]
I thought that this would return an object that would allow me to get either the text or the value of the option. However, it seems to just return the text as a string. I really want to be able to get the value of the selected option (the text could change and make the text fail, but the value is fixed).
In the API documentation I noticed the Watir::OptionAccess object which allows access to both the value and the text, but I can't see any way to get this object.
Maybe I'm missing something.
Thanks,
Ben Mills
|
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general