lib/kelp/field.rb
# Select a value from a dropdown or listbox, or fill in a text field,
# depending on what kind of form field is available. If `field` is a
# dropdown or listbox, select `value` from that; otherwise, assume
# `field` is a text box.
#
# @param [String] field
#   Capybara locator for the field (name, id, or label text)
# @param [String] value
#   Text to select from a dropdown or enter in a text box
#
# @raise [Kelp::AmbiguousField]
#   If more than one field matching `field` is found
# @raise [Kelp::FieldNotFound]
#   If no field matching `field` is found
# @raise [Kelp::OptionNotFound]
#   If a dropdown matching `field` is found, but it has no
#   option matching `value`
#
# @since 0.1.9
#
Select a value from a dropdown or listbox, or fill in a text field,
depending on what kind of form field is available.
Select a value from a dropdown or listbox or fill in a text field depending on what kind of form field is available .
def select_or_fill(field, value)
      case field_type(field)
      when :select
        begin
          select(value, :from => field)
        rescue Capybara::ElementNotFound
          raise Kelp::OptionNotFound,
            "Field '#{field}' has no option '#{value}'"
        end
      when :fillable_field
        fill_in(field, :with => value)
      end
    end
def select_or_fill ( field , value ) case field_type ( field ) when :select begin select ( value , :from => field ) rescue Capybara :: ElementNotFound raise Kelp :: OptionNotFound , "Field '#{field}' has no option '#{value}'" end when :fillable_field fill_in ( field , :with => value ) end end
Select a value from a dropdown or listbox, or fill in a text field,
depending on what kind of form field is available.
Select a value from a dropdown or listbox or fill in a text field depending on what kind of form field is available .
[Kelp::AmbiguousField] If more than one field matching `field` is found
[ Kelp :: AmbiguousField ] If more than one field matching ` field ` is found
[Kelp::FieldNotFound] If no field matching `field` is found
[ Kelp :: FieldNotFound ] If no field matching ` field ` is found
[Kelp::OptionNotFound] If a dropdown matching `field` is found, but it has no option matching `value`
[ Kelp :: OptionNotFound ] If a dropdown matching ` field ` is found but it has no option matching ` value `
field
<not_specific>
value
<not_specific>
<not_specific>
value Text to select from a dropdown or enter in a text box
value Text to select from a dropdown or enter in a text box
since
None