diff --git a/lib/webrat/core/locators.rb b/lib/webrat/core/locators.rb index 2d91e8b..2ecc0ee 100644 --- a/lib/webrat/core/locators.rb +++ b/lib/webrat/core/locators.rb @@ -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)