Sha256: 5ddd7eef6cec84c11c2c106235102a9e3d5a1c7bd4debed548230979228115d9

Contents?: true

Size: 910 Bytes

Versions: 44

Compression:

Stored size: 910 Bytes

Contents

require "webrat/core/locators/locator"

module Webrat
  module Locators
    
    class FieldNamedLocator < Locator # :nodoc:
  
      def locate
        Field.load(@session, field_element)
      end
  
      def field_element
        field_elements.detect do |field_element|
          Webrat::XML.attribute(field_element, "name") == @value.to_s
        end
      end
  
      def field_elements
        Webrat::XML.xpath_search(@dom, *xpath_searches)
      end
  
      def xpath_searches
        if @field_types.any?
          @field_types.map { |field_type| field_type.xpath_search }.flatten
        else
          Array(Field.xpath_search)
        end
      end
  
      def error_message
        "Could not find field named #{@value.inspect}"
      end
      
    end
    
    def field_named(name, *field_types)
      FieldNamedLocator.new(@session, dom, name, *field_types).locate!
    end
    
  end
end

Version data entries

44 entries across 44 versions & 14 rubygems

Version Path
adva-0.3.2 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.3.1 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.3.0 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.2.4 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.2.3 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.2.2 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.2.1 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.2.0 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.1.4 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.1.3 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.1.2 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.1.1 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.1.0 test/webrat/lib/webrat/core/locators/field_named_locator.rb
adva-0.0.1 test/webrat/lib/webrat/core/locators/field_named_locator.rb
aslakhellesoy-webrat-0.3.2.1 lib/webrat/core/locators/field_named_locator.rb
aslakhellesoy-webrat-0.3.2.2 lib/webrat/core/locators/field_named_locator.rb
auxesis-webrat-0.4.1 lib/webrat/core/locators/field_named_locator.rb
benschwarz-webrat-0.3.2.1 lib/webrat/core/locators/field_named_locator.rb
brynary-webrat-0.3.2.1 lib/webrat/core/locators/field_named_locator.rb
brynary-webrat-0.3.2.2 lib/webrat/core/locators/field_named_locator.rb