Updating SelectOptionLocator to use elements

This commit is contained in:
Bryan Helmkamp 2008-11-30 15:15:50 -05:00
parent ac4feb3b7e
commit 0eee6d75e4

View File

@ -13,7 +13,6 @@ module Webrat
end end
def locate def locate
# TODO - Convert to using elements
if @id_or_name_or_label if @id_or_name_or_label
field = FieldLocator.new(@scope, @id_or_name_or_label, SelectField).locate! field = FieldLocator.new(@scope, @id_or_name_or_label, SelectField).locate!
@ -25,19 +24,20 @@ module Webrat
end end
end end
else else
@scope.send(:forms).detect_mapped do |form| option_element = option_elements.detect do |o|
select_fields = form.send(:fields_by_type, [SelectField])
select_fields.detect_mapped do |select_field|
select_field.send(:options).detect do |o|
if @option_text.is_a?(Regexp) if @option_text.is_a?(Regexp)
Webrat::XML.inner_html(o.element) =~ @option_text Webrat::XML.inner_html(o) =~ @option_text
else else
Webrat::XML.inner_html(o.element) == @option_text.to_s Webrat::XML.inner_html(o) == @option_text.to_s
end
end end
end end
SelectOption.load(@scope.session, option_element)
end end
end end
def option_elements
Webrat::XML.xpath_search(@scope.dom, *SelectOption.xpath_search)
end end
def error_message def error_message