Switching field_named locator to use elements

This commit is contained in:
Bryan Helmkamp 2008-11-29 01:14:49 -05:00
parent 4736c4cb1a
commit 4a63c9bfd1

View File

@ -37,9 +37,18 @@ module Webrat
end end
def find_field_named(name, *field_types) #:nodoc: def find_field_named(name, *field_types) #:nodoc:
forms.detect_mapped do |form| if field_types.any?
form.field_named(name, *field_types) xpath_searches = field_types.map { |field_type| field_type.xpath_search }.flatten
field_elements = Webrat::XML.xpath_search(dom, xpath_searches)
else
field_elements = Webrat::XML.xpath_search(dom, *Field.xpath_search)
end end
field_element = field_elements.detect do |field_element|
Webrat::XML.attribute(field_element, "name") == name.to_s
end
field_by_element(field_element)
end end
def field_by_element(element, *field_types) def field_by_element(element, *field_types)