Moving locator methods
This commit is contained in:
parent
1647d6ec1e
commit
f843ac2ae3
|
@ -29,47 +29,5 @@ module Webrat
|
||||||
raise(NotFoundError.new("Could not find field: #{args.inspect}"))
|
raise(NotFoundError.new("Could not find field: #{args.inspect}"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def field_labeled(label, *field_types)
|
|
||||||
FieldLabeledLocator.new(self, label, *field_types).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find field labeled #{label.inspect}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def field_named(name, *field_types)
|
|
||||||
FieldNamedLocator.new(self, name, *field_types).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find field named #{name.inspect}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def field_with_id(id, *field_types)
|
|
||||||
FieldByIdLocator.new(self, id, *field_types).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find field with id #{id.inspect}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_select_option(option_text, id_or_name_or_label) #:nodoc:
|
|
||||||
option = SelectOptionLocator.new(self, option_text, id_or_name_or_label).locate
|
|
||||||
return option if option
|
|
||||||
|
|
||||||
if id_or_name_or_label
|
|
||||||
select_box_text = " in the #{id_or_name_or_label.inspect} select box"
|
|
||||||
raise NotFoundError.new("The '#{option_text}' option was not found#{select_box_text}")
|
|
||||||
else
|
|
||||||
raise NotFoundError.new("Could not find option #{option_text.inspect}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_button(value) #:nodoc:
|
|
||||||
ButtonLocator.new(self, value).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find button #{value.inspect}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_area(id_or_title) #:nodoc:
|
|
||||||
AreaLocator.new(self, id_or_title).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find area with name #{id_or_title}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_link(text_or_title_or_id) #:nodoc:
|
|
||||||
LinkLocator.new(self, text_or_title_or_id).locate ||
|
|
||||||
raise(NotFoundError.new("Could not find link with text or title or id #{text_or_title_or_id.inspect}"))
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,5 +26,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_area(id_or_title) #:nodoc:
|
||||||
|
AreaLocator.new(self, id_or_title).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find area with name #{id_or_title}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -42,5 +42,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_button(value) #:nodoc:
|
||||||
|
ButtonLocator.new(self, value).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find button #{value.inspect}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -25,5 +25,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def field_with_id(id, *field_types)
|
||||||
|
FieldByIdLocator.new(self, id, *field_types).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find field with id #{id.inspect}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -14,5 +14,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def field_labeled(label, *field_types)
|
||||||
|
FieldLabeledLocator.new(self, label, *field_types).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find field labeled #{label.inspect}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -29,5 +29,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def field_named(name, *field_types)
|
||||||
|
FieldNamedLocator.new(self, name, *field_types).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find field named #{name.inspect}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -54,5 +54,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_link(text_or_title_or_id) #:nodoc:
|
||||||
|
LinkLocator.new(self, text_or_title_or_id).locate ||
|
||||||
|
raise(NotFoundError.new("Could not find link with text or title or id #{text_or_title_or_id.inspect}"))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -13,7 +13,6 @@ module Webrat
|
||||||
|
|
||||||
def locate
|
def locate
|
||||||
# TODO - Convert to using elements
|
# TODO - Convert to using elements
|
||||||
|
|
||||||
if @id_or_name_or_label
|
if @id_or_name_or_label
|
||||||
field = @scope.field(@id_or_name_or_label, SelectField)
|
field = @scope.field(@id_or_name_or_label, SelectField)
|
||||||
field.find_option(@option_text)
|
field.find_option(@option_text)
|
||||||
|
@ -26,5 +25,17 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_select_option(option_text, id_or_name_or_label) #:nodoc:
|
||||||
|
option = SelectOptionLocator.new(self, option_text, id_or_name_or_label).locate
|
||||||
|
return option if option
|
||||||
|
|
||||||
|
if id_or_name_or_label
|
||||||
|
select_box_text = " in the #{id_or_name_or_label.inspect} select box"
|
||||||
|
raise NotFoundError.new("The '#{option_text}' option was not found#{select_box_text}")
|
||||||
|
else
|
||||||
|
raise NotFoundError.new("Could not find option #{option_text.inspect}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue