brynary/webrat

View on GitHub
lib/webrat/core/locators/field_locator.rb

Summary

Maintainability
A
0 mins
Test Coverage
require "webrat/core/locators/locator"

module Webrat
  module Locators

    class FieldLocator < Locator # :nodoc:

      def locate
        FieldByIdLocator.new(@session, @dom, @value).locate   ||
        FieldNamedLocator.new(@session, @dom, @value, *@field_types).locate   ||
        FieldLabeledLocator.new(@session, @dom, @value, *@field_types).locate
      end

      def error_message
        "Could not find field: #{@value.inspect}"
      end

    end

    def field(*args) # :nodoc:
      FieldLocator.new(@session, dom, *args).locate!
    end

  end
end