Updating SelectOptionLocator to use elements
This commit is contained in:
parent
ac4feb3b7e
commit
0eee6d75e4
@ -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,21 +24,22 @@ 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])
|
if @option_text.is_a?(Regexp)
|
||||||
select_fields.detect_mapped do |select_field|
|
Webrat::XML.inner_html(o) =~ @option_text
|
||||||
select_field.send(:options).detect do |o|
|
else
|
||||||
if @option_text.is_a?(Regexp)
|
Webrat::XML.inner_html(o) == @option_text.to_s
|
||||||
Webrat::XML.inner_html(o.element) =~ @option_text
|
|
||||||
else
|
|
||||||
Webrat::XML.inner_html(o.element) == @option_text.to_s
|
|
||||||
end
|
|
||||||
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
|
||||||
|
|
||||||
def error_message
|
def error_message
|
||||||
if @id_or_name_or_label
|
if @id_or_name_or_label
|
||||||
"The '#{@option_text}' option was not found in the #{@id_or_name_or_label.inspect} select box"
|
"The '#{@option_text}' option was not found in the #{@id_or_name_or_label.inspect} select box"
|
||||||
|
Loading…
Reference in New Issue
Block a user