Extract FieldLocator
This commit is contained in:
parent
f843ac2ae3
commit
53ba0cc691
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue