Class: Formulaic::Inputs::StringInput

Inherits:
Input
  • Object
show all
Defined in:
lib/formulaic/inputs/string_input.rb

Instance Method Summary collapse

Methods inherited from Input

#initialize

Constructor Details

This class inherits a constructor from Formulaic::Inputs::Input

Instance Method Details

#fillObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/formulaic/inputs/string_input.rb', line 4

def fill
  if page.has_selector?(:fillable_field, label, wait: Formulaic.default_wait_time)
    fill_in(label, with: value)
  elsif page.has_selector?(:radio_button, label, wait: Formulaic.default_wait_time)
    choose(value)
  elsif has_option_in_select?(translate_option(value), label)
    select(translate_option(value), from: label)
  else
    raise Formulaic::InputNotFound.new(%[Unable to find input "#{label}".])
  end
end

#has_option_in_select?(option, select) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'lib/formulaic/inputs/string_input.rb', line 16

def has_option_in_select?(option, select)
  element = find(:select, select)
  if ! element.has_selector?(:option, option, wait: Formulaic.default_wait_time)
    raise Formulaic::OptionForSelectInputNotFound.new(%[Unable to find option with text matching "#{option}".])
  end
  true
rescue Capybara::ElementNotFound
  false
end