Moving locator methods

This commit is contained in:
Bryan Helmkamp 2008-11-29 23:08:23 -05:00
parent 1647d6ec1e
commit f843ac2ae3
8 changed files with 42 additions and 43 deletions

View File

@ -29,47 +29,5 @@ module Webrat
raise(NotFoundError.new("Could not find field: #{args.inspect}"))
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

View File

@ -26,5 +26,10 @@ module Webrat
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

View File

@ -42,5 +42,10 @@ module Webrat
end
def find_button(value) #:nodoc:
ButtonLocator.new(self, value).locate ||
raise(NotFoundError.new("Could not find button #{value.inspect}"))
end
end
end

View File

@ -25,5 +25,10 @@ module Webrat
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

View File

@ -14,5 +14,10 @@ module Webrat
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

View File

@ -29,5 +29,10 @@ module Webrat
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

View File

@ -54,5 +54,10 @@ module Webrat
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

View File

@ -13,7 +13,6 @@ module Webrat
def locate
# TODO - Convert to using elements
if @id_or_name_or_label
field = @scope.field(@id_or_name_or_label, SelectField)
field.find_option(@option_text)
@ -26,5 +25,17 @@ module Webrat
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