Sha256: 4ddf34f74aa8eea1b6f7f2027d1723a9359bdf90f108909381169f82b3e1a51f

Contents?: true

Size: 834 Bytes

Versions: 44

Compression:

Stored size: 834 Bytes

Contents

require "webrat/core/locators/locator"

module Webrat
  module Locators
    
    class FieldByIdLocator < Locator # :nodoc:
  
      def locate
        Field.load(@session, field_element)
      end
  
      def field_element
        field_elements.detect do |field_element|
          if @value.is_a?(Regexp)
            Webrat::XML.attribute(field_element, "id") =~ @value
          else
            Webrat::XML.attribute(field_element, "id") == @value.to_s
          end
        end
      end
  
      def field_elements
        Webrat::XML.xpath_search(@dom, *Field.xpath_search)
      end

      def error_message
        "Could not find field with id #{@value.inspect}"
      end
      
    end
    
    def field_with_id(id, *field_types)
      FieldByIdLocator.new(@session, dom, id, *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_by_id_locator.rb
adva-0.3.1 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.3.0 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.2.4 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.2.3 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.2.2 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.2.1 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.2.0 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.1.4 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.1.3 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.1.2 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.1.1 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.1.0 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
adva-0.0.1 test/webrat/lib/webrat/core/locators/field_by_id_locator.rb
aslakhellesoy-webrat-0.3.2.1 lib/webrat/core/locators/field_by_id_locator.rb
aslakhellesoy-webrat-0.3.2.2 lib/webrat/core/locators/field_by_id_locator.rb
auxesis-webrat-0.4.1 lib/webrat/core/locators/field_by_id_locator.rb
benschwarz-webrat-0.3.2.1 lib/webrat/core/locators/field_by_id_locator.rb
brynary-webrat-0.3.2.1 lib/webrat/core/locators/field_by_id_locator.rb
brynary-webrat-0.3.2.2 lib/webrat/core/locators/field_by_id_locator.rb