From 4a63c9bfd1f6ed9d46be24c9d008a8d3e5da5506 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 29 Nov 2008 01:14:49 -0500 Subject: [PATCH] Switching field_named locator to use elements --- lib/webrat/core/locators.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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)