Extract FieldLocator

This commit is contained in:
Bryan Helmkamp 2008-11-29 23:11:16 -05:00
parent f843ac2ae3
commit 53ba0cc691
2 changed files with 19 additions and 3 deletions

View File

@ -8,6 +8,7 @@ require "webrat/core/locators/field_named_locator"
require "webrat/core/locators/field_by_id_locator"
require "webrat/core/locators/select_option_locator"
require "webrat/core/locators/link_locator"
require "webrat/core/locators/field_locator"
module Webrat
module Locators
@ -23,9 +24,7 @@ module Webrat
def field(*args) # :nodoc:
# This is the default locator strategy
FieldByIdLocator.new(self, args.first).locate ||
FieldNamedLocator.new(self, *args).locate ||
FieldLabeledLocator.new(self, *args).locate ||
FieldLocator.new(self, *args).locate ||
raise(NotFoundError.new("Could not find field: #{args.inspect}"))
end

View File

@ -0,0 +1,17 @@
require "webrat/core/locators/locator"
module Webrat
module Locators
class FieldLocator < Locator
def locate
FieldByIdLocator.new(@scope, @value).locate ||
FieldNamedLocator.new(@scope, @value, *@field_types).locate ||
FieldLabeledLocator.new(@scope, @value, *@field_types).locate
end
end
end
end