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
1 changed files with 11 additions and 2 deletions

View File

@ -37,9 +37,18 @@ module Webrat
end
def find_field_named(name, *field_types) #:nodoc:
forms.detect_mapped do |form|
form.field_named(name, *field_types)
if field_types.any?
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
field_element = field_elements.detect do |field_element|
Webrat::XML.attribute(field_element, "name") == name.to_s
end
field_by_element(field_element)
end
def field_by_element(element, *field_types)