Class: FillIN::JsSelect

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/pickles/steps/fill_in/js_select.rb

Instance Method Summary collapse

Constructor Details

#initialize(label, value, within) ⇒ JsSelect

Returns a new instance of JsSelect.



3
4
5
6
7
# File 'lib/cucumber/pickles/steps/fill_in/js_select.rb', line 3

def initialize(label, value, within)
  @label = label
  @value = value
  @within = within || Capybara.current_session
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber/pickles/steps/fill_in/js_select.rb', line 9

def call
  locator, index = Locator::Index.execute(@value)
  locator, xpath = Locator::Equal.execute(locator)

  index ||= 1

  input = FillIN::Input.new(@label, locator, @within).call

  Waiter.wait do
    # prev version "(./ancestor::*[#{xpath}][#{index}]/#{xpath})[#{index}]"
    input.find(:xpath, "(./ancestor::*[#{xpath}]/#{xpath})[#{index}]").click
  end

  Pickles.blur(input)

  Waiter.wait_for_ajax

  input
end