Module: Daddy::Cucumber::Html

Defined in:
lib/daddy/cucumber/helpers/html.rb

Instance Method Summary collapse

Instance Method Details

#confirm(ok = true) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/daddy/cucumber/helpers/html.rb', line 39

def confirm(ok = true)
  return unless Capybara.current_driver == :selenium

  if ok
    page.driver.browser.switch_to.alert.accept
  else
    page.driver.browser.switch_to.alert.deny
  end
end

#find_option(select_selector, text, fail_on_missing = true) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/daddy/cucumber/helpers/html.rb', line 22

def find_option(select_selector, text, fail_on_missing = true)
  within select_selector do
    all('option').each do |option|
      if option.text.include?(text)
        if block_given?
          within option do
            yield
          end
        end
        return option
      end
    end
  end
  
  fail "セレクトボックス #{select_selector} 内に #{text} を含むオプションが見つかりませでした。" if fail_on_missing
end

#find_tr(table_selector, text, fail_on_missing = true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/daddy/cucumber/helpers/html.rb', line 5

def find_tr(table_selector, text, fail_on_missing = true)
  within table_selector do
    all('tr').each do |tr|
      if tr.text.include?(text)
        if block_given?
          within tr do
            yield tr
          end
        end
        return tr
      end
    end
  end
  
  fail "テーブル #{table_selector} 内に #{text} を含む行が見つかりませでした。" if fail_on_missing
end