lib/kelp/field.rb
# Figure out whether the field locator matches a single select
# or fillable field.
#
# @param [String] field
#   Capybara locator for the field (name, id, or label text)
#
# @raise [Kelp::AmbiguousField]
#   If more than one field matching `field` is found
# @raise [Kelp::FieldNotFound]
#   If no field matching `field` is found
#
# @return [Symbol]
#   `:select` or `:fillable_field` depending on the type of element
Figure out whether the field locator matches a single select
or fillable field.
Figure out whether the field locator matches a single select or fillable field .
def field_type(field)
      select = all(:select, field).count
      fillable = all(:fillable_field, field).count
      count = select + fillable
      case count
      when 0
        raise Kelp::FieldNotFound,
          "No field with id, name, or label '#{field}' found"
      when 1
        return select > 0 ? :select : :fillable_field
      else
        raise Kelp::AmbiguousField,
          "Field '#{field}' is ambiguous"
      end
    end
def field_type ( field ) select = all ( :select , field ) . count fillable = all ( :fillable_field , field ) . count count = select + fillable case count when 0 raise Kelp :: FieldNotFound , "No field with id, name, or label '#{field}' found" when 1 return select > 0 ? :select : :fillable_field else raise Kelp :: AmbiguousField , "Field '#{field}' is ambiguous" end end
Figure out whether the field locator matches a single select
or fillable field.
Figure out whether the field locator matches a single select or fillable field .
`:select` or `:fillable_field` depending on the type of element
` : select ` or ` : fillable_field ` depending on the type of element
Symbol
[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
field
<not_specific>
<not_specific>
field Capybara locator for the field (name, id, or label text)
field Capybara locator for the field ( name id or label text )