Module: Cello::PageObjects::RadioHelper

Included in:
ElementHelper
Defined in:
lib/cello/pageobjects/html_elements/radio_helper.rb

Instance Method Summary collapse

Instance Method Details

#define_extras_for_radios(name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cello/pageobjects/html_elements/radio_helper.rb', line 4

def define_extras_for_radios(name)
  define_method "#{name}_is_real?" do
    send(name).size > 0
  end
  define_method "#{name}_click" do
    send(name)[0].click
  end
  define_method "#{name}_is_visible?" do
    send(name).all? {|e| e.visible?}
  end
  define_method "#{name}_right_click" do
    send(name)[0].right_click
  end
  define_method "#{name}_is_enable?" do
    send(name).all? {|e| e.enabled?}
  end
  define_method "#{name}_contains" do |radio_value|
    send(name).any? {|e| e.value == radio_value}
  end
  define_method "#{name}_has_selected_option?" do
    send(name).any? {|e| e.checked? == true}
  end
  define_method "#{name}_set" do |radio_value|
    send(name).each do |element|
      element.value == radio_value ? element.set : nil
    end
  end
  define_method "#{name}_checked_option_is?" do |radio_value|
    foo = false
    send(name).each do |element|
      if (element.value == radio_value && element.checked?) 
        foo = true
      end
    end
    return foo
  end
  define_method "#{name}_checked_option_is_not?" do |radio_value|
    foo = false
    send(name).each do |element|
      if (element.value == radio_value && element.checked?) 
        foo = true
      end
    end
    return !foo
  end
  define_method "#{name}_checked_option?" do
    send(name).each {|e| p e.value.size if (e.checked?) }
  end
end