Sha256: a7e00a4f4ca6951b979437f62d64078428b4a746eaa6d14d07f904ce4ca482e7

Contents?: true

Size: 811 Bytes

Versions: 49

Compression:

Stored size: 811 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

49 entries across 49 versions & 21 rubygems

Version Path
aslakhellesoy-webrat-0.4.4.1 lib/webrat/core/locators/field_by_id_locator.rb
casebook-webrat-0.4.4.1 lib/webrat/core/locators/field_by_id_locator.rb
cavalle-webrat-0.4.4.1 lib/webrat/core/locators/field_by_id_locator.rb
cavalle-webrat-0.4.4.2 lib/webrat/core/locators/field_by_id_locator.rb
davidtrogers-webrat-0.4.4.2 lib/webrat/core/locators/field_by_id_locator.rb
dbrady-webrat-0.4.4.1 lib/webrat/core/locators/field_by_id_locator.rb
dbrady-webrat-0.4.4.2 lib/webrat/core/locators/field_by_id_locator.rb
dbrady-webrat-0.4.4 lib/webrat/core/locators/field_by_id_locator.rb
diabolo-diabolo-webrat-0.4.4 lib/webrat/core/locators/field_by_id_locator.rb
diabolo-webrat-0.4.3 lib/webrat/core/locators/field_by_id_locator.rb
diabolo-webrat-0.4.4.1 lib/webrat/core/locators/field_by_id_locator.rb
diabolo-webrat-0.4.4.2 lib/webrat/core/locators/field_by_id_locator.rb
diabolo-webrat-0.4.4 lib/webrat/core/locators/field_by_id_locator.rb
dstrelau-webrat-0.5.1 lib/webrat/core/locators/field_by_id_locator.rb
emipair-webrat-0.0.1 lib/webrat/core/locators/field_by_id_locator.rb
futuresinc-webrat-0.4.4.100 lib/webrat/core/locators/field_by_id_locator.rb
futuresinc-webrat-0.4.4.99 lib/webrat/core/locators/field_by_id_locator.rb
garnierjm-webrat-0.4.5 lib/webrat/core/locators/field_by_id_locator.rb
hardbap-webrat-0.5.1 lib/webrat/core/locators/field_by_id_locator.rb
hardbap-webrat-0.5.2 lib/webrat/core/locators/field_by_id_locator.rb