testcentricity_web 2.1.8.2 → 2.1.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +27 -0
  3. data/.rubocop.yml +41 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +28 -0
  7. data/README.md +1438 -0
  8. data/Rakefile +1 -0
  9. data/lib/devices/devices.yml +280 -0
  10. data/lib/testcentricity_web.rb +140 -0
  11. data/lib/testcentricity_web/browser_helper.rb +173 -0
  12. data/lib/testcentricity_web/data_objects_helper.rb +78 -0
  13. data/lib/testcentricity_web/drag_drop_helper.rb +15 -0
  14. data/lib/testcentricity_web/elements/button.rb +8 -0
  15. data/lib/testcentricity_web/elements/cell_button.rb +8 -0
  16. data/lib/testcentricity_web/elements/cell_checkbox.rb +38 -0
  17. data/lib/testcentricity_web/elements/cell_element.rb +62 -0
  18. data/lib/testcentricity_web/elements/cell_image.rb +8 -0
  19. data/lib/testcentricity_web/elements/cell_radio.rb +31 -0
  20. data/lib/testcentricity_web/elements/checkbox.rb +99 -0
  21. data/lib/testcentricity_web/elements/file_field.rb +45 -0
  22. data/lib/testcentricity_web/elements/image.rb +34 -0
  23. data/lib/testcentricity_web/elements/label.rb +8 -0
  24. data/lib/testcentricity_web/elements/link.rb +8 -0
  25. data/lib/testcentricity_web/elements/list.rb +54 -0
  26. data/lib/testcentricity_web/elements/list_button.rb +8 -0
  27. data/lib/testcentricity_web/elements/list_checkbox.rb +38 -0
  28. data/lib/testcentricity_web/elements/list_element.rb +51 -0
  29. data/lib/testcentricity_web/elements/list_radio.rb +31 -0
  30. data/lib/testcentricity_web/elements/radio.rb +73 -0
  31. data/lib/testcentricity_web/elements/select_list.rb +189 -0
  32. data/lib/testcentricity_web/elements/table.rb +473 -0
  33. data/lib/testcentricity_web/elements/textfield.rb +84 -0
  34. data/lib/testcentricity_web/environment.rb +249 -0
  35. data/lib/testcentricity_web/excel_helper.rb +242 -0
  36. data/lib/testcentricity_web/exception_queue_helper.rb +47 -0
  37. data/lib/testcentricity_web/page_objects_helper.rb +656 -0
  38. data/lib/testcentricity_web/page_sections_helper.rb +811 -0
  39. data/lib/testcentricity_web/siebel_open_ui_helper.rb +15 -0
  40. data/lib/testcentricity_web/ui_elements_helper.rb +425 -0
  41. data/lib/testcentricity_web/utility_helpers.rb +28 -0
  42. data/lib/testcentricity_web/version.rb +3 -0
  43. data/lib/testcentricity_web/webdriver_helper.rb +451 -0
  44. data/lib/testcentricity_web/world_extensions.rb +26 -0
  45. data/testcentricity_web.gemspec +42 -0
  46. metadata +52 -4
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class Link < UIElement
3
+ def initialize(name, parent, locator, context)
4
+ super
5
+ @type = :link
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,54 @@
1
+ module TestCentricity
2
+ class List < UIElement
3
+ attr_accessor :list_item
4
+
5
+ def initialize(name, parent, locator, context)
6
+ super
7
+ @type = :list
8
+ define_list_elements({ :list_item => 'li' })
9
+ end
10
+
11
+ def define_list_elements(element_spec)
12
+ element_spec.each do |element, value|
13
+ case element
14
+ when :list_item
15
+ @list_item = value
16
+ end
17
+ end
18
+ end
19
+
20
+ def get_list_items(element_spec = nil)
21
+ define_list_elements(element_spec) unless element_spec.nil?
22
+ obj, = find_element
23
+ object_not_found_exception(obj, nil)
24
+ obj.all(@list_item).collect(&:text)
25
+ end
26
+
27
+ def get_list_item(index)
28
+ items = get_list_items
29
+ items[index - 1]
30
+ end
31
+
32
+ def get_item_count
33
+ obj, = find_element
34
+ object_not_found_exception(obj, nil)
35
+ obj.all(@list_item).count
36
+ end
37
+
38
+ def verify_list_items(expected, enqueue = false)
39
+ actual = get_list_items
40
+ enqueue ?
41
+ ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list #{object_ref_message}") :
42
+ assert_equal(expected, actual, "Expected list #{object_ref_message} to be #{expected} but found #{actual}")
43
+ end
44
+
45
+ def click_item(row)
46
+ list_item = get_list_row_locator(row)
47
+ list_item.click
48
+ end
49
+
50
+ def get_list_row_locator(row)
51
+ "#{@locator}/#{@list_item}[#{row}]"
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ module TestCentricity
2
+ class ListButton < ListElement
3
+ def initialize(name, parent, locator, context, list, proxy = nil)
4
+ super
5
+ @type = :list_button
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module TestCentricity
2
+ class ListCheckBox < ListElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, list, proxy = nil)
6
+ super
7
+ @type = :list_checkbox
8
+ @proxy = proxy
9
+ end
10
+
11
+ def checked?(row)
12
+ obj, = find_list_element(row)
13
+ list_object_not_found_exception(obj, 'List CheckBox', row)
14
+ obj.checked?
15
+ end
16
+
17
+ def set_checkbox_state(row, state)
18
+ obj, = find_list_element(row)
19
+ list_object_not_found_exception(obj, 'List CheckBox', row)
20
+ obj.set(state)
21
+ end
22
+
23
+ def check(row)
24
+ set_checkbox_state(row, true)
25
+ end
26
+
27
+ def uncheck(row)
28
+ set_checkbox_state(row, false)
29
+ end
30
+
31
+ def verify_check_state(row, state, enqueue = false)
32
+ actual = checked?(row)
33
+ enqueue ?
34
+ ExceptionQueue.enqueue_assert_equal(state, actual, "Expected Row #{row} List Checkbox #{object_ref_message}") :
35
+ assert_equal(state, actual, "Expected Row #{row} List Checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,51 @@
1
+ module TestCentricity
2
+ class ListElement < UIElement
3
+ attr_accessor :list
4
+ attr_accessor :element_locator
5
+
6
+ def initialize(name, parent, locator, context, list, proxy = nil)
7
+ @name = name
8
+ @parent = parent
9
+ @context = context
10
+ @alt_locator = nil
11
+ @list = list
12
+ @element_locator = locator
13
+ locator.nil? ?
14
+ @locator = list.get_list_row_locator('ROW_SPEC') :
15
+ @locator = "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
16
+ end
17
+
18
+ def exists?(row)
19
+ obj, = find_list_element(row)
20
+ obj != nil
21
+ end
22
+
23
+ def click(row)
24
+ obj, = find_list_element(row)
25
+ list_object_not_found_exception(obj, @type, row)
26
+ obj.click
27
+ end
28
+
29
+ def get_value(row, visible = true)
30
+ obj, = find_list_element(row, visible)
31
+ list_object_not_found_exception(obj, @type, row)
32
+ case obj.tag_name.downcase
33
+ when 'input', 'select', 'textarea'
34
+ obj.value
35
+ else
36
+ obj.text
37
+ end
38
+ end
39
+
40
+ alias get_caption get_value
41
+
42
+ def find_list_element(row, visible = true)
43
+ set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
44
+ find_element(visible)
45
+ end
46
+
47
+ def list_object_not_found_exception(obj, obj_type, row)
48
+ object_not_found_exception(obj, "Row #{row} #{obj_type}")
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,31 @@
1
+ module TestCentricity
2
+ class ListRadio < ListElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, list, proxy = nil)
6
+ super
7
+ @type = :list_radio
8
+ @proxy = proxy
9
+ end
10
+
11
+ def selected?(row)
12
+ obj, = find_list_element(row)
13
+ list_object_not_found_exception(obj, 'List Radio', row)
14
+ obj.checked?
15
+ end
16
+
17
+ def set_selected_state(row, state)
18
+ obj, = find_list_element(row)
19
+ list_object_not_found_exception(obj, 'List Radio', row)
20
+ obj.set(state)
21
+ end
22
+
23
+ def select(row)
24
+ set_selected_state(row, true)
25
+ end
26
+
27
+ def unselect(row)
28
+ set_selected_state(row, false)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,73 @@
1
+ module TestCentricity
2
+ class Radio < UIElement
3
+ attr_accessor :proxy
4
+
5
+ def initialize(name, parent, locator, context, proxy = nil)
6
+ @name = name
7
+ @parent = parent
8
+ @locator = locator
9
+ @context = context
10
+ @alt_locator = nil
11
+ @proxy = proxy
12
+ @type = :radio
13
+ end
14
+
15
+ # Does radio button object exists?
16
+ #
17
+ # @return [Boolean]
18
+ # @example
19
+ # accept_terms_radio.exists?
20
+ #
21
+ def exists?
22
+ obj, = find_object(:all)
23
+ obj != nil
24
+ end
25
+
26
+ # Is radio button selected?
27
+ #
28
+ # @return [Boolean]
29
+ # @example
30
+ # accept_terms_radio.selected?
31
+ #
32
+ def selected?
33
+ obj, = find_element(:all)
34
+ object_not_found_exception(obj, 'Radio')
35
+ obj.checked?
36
+ end
37
+
38
+ # Set the select state of a radio button object.
39
+ #
40
+ # @param state [Boolean] true = selected / false = unselected
41
+ # @example
42
+ # accept_terms_radio.set_selected_state(true)
43
+ #
44
+ def set_selected_state(state)
45
+ obj, = find_element(:all)
46
+ object_not_found_exception(obj, 'Radio')
47
+ invalid_object_type_exception(obj, 'radio')
48
+ if @proxy.nil?
49
+ obj.set(state)
50
+ else
51
+ @proxy.click unless state == obj.checked?
52
+ end
53
+ end
54
+
55
+ # Set the selected state of a radio button object.
56
+ #
57
+ # @example
58
+ # accept_terms_radio.select
59
+ #
60
+ def select
61
+ set_selected_state(true)
62
+ end
63
+
64
+ # Unselect a radio button object.
65
+ #
66
+ # @example
67
+ # accept_terms_radio.unselect
68
+ #
69
+ def unselect
70
+ set_selected_state(false)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,189 @@
1
+ module TestCentricity
2
+ class SelectList < UIElement
3
+ attr_accessor :list_item
4
+ attr_accessor :selected_item
5
+
6
+ def initialize(name, parent, locator, context)
7
+ super
8
+ @type = :selectlist
9
+ list_spec = {
10
+ :list_item => 'option',
11
+ :selected_item => 'option[selected]'
12
+ }
13
+ define_list_elements(list_spec)
14
+ end
15
+
16
+ def define_list_elements(element_spec)
17
+ element_spec.each do |element, value|
18
+ case element
19
+ when :list_item
20
+ @list_item = value
21
+ when :selected_item
22
+ @selected_item = value
23
+ end
24
+ end
25
+ end
26
+
27
+ # Select the specified option in a select box object. Accepts a String or Hash.
28
+ # Supports standard HTML select objects and Chosen select objects.
29
+ #
30
+ # @param option [String] text of option to select
31
+ # OR
32
+ # @param option [Hash] :value, :index, or :text of option to select
33
+ #
34
+ # @example
35
+ # province_select.choose_option('Alberta')
36
+ # province_select.choose_option(:value => 'AB')
37
+ # state_select.choose_option(:index => 24)
38
+ # state_select.choose_option(:text => 'Maryland')
39
+ #
40
+ def choose_option(option)
41
+ obj, = find_element
42
+ object_not_found_exception(obj, nil)
43
+ obj.click
44
+ if first(:css, 'li.active-result')
45
+ if option.is_a?(Array)
46
+ option.each do |item|
47
+ page.find(:css, 'li.active-result', text: item.strip).click
48
+ end
49
+ else
50
+ first(:css, 'li.active-result', text: option).click
51
+ end
52
+ else
53
+ if option.is_a?(Array)
54
+ option.each do |item|
55
+ select_item(obj, item)
56
+ end
57
+ else
58
+ select_item(obj, option)
59
+ end
60
+ end
61
+ end
62
+
63
+ # Return array of strings of all options in a select box object.
64
+ # Supports standard HTML select objects and Chosen select objects.
65
+ #
66
+ # @return [Array]
67
+ # @example
68
+ # all_colors = color_select.get_options
69
+ #
70
+ def get_options
71
+ obj, = find_element
72
+ object_not_found_exception(obj, nil)
73
+ if first(:css, 'li.active-result')
74
+ obj.all('li.active-result').collect(&:text)
75
+ else
76
+ obj.all(@list_item).collect(&:text)
77
+ end
78
+ end
79
+
80
+ alias get_list_items get_options
81
+
82
+ # Return the number of options in a select box object.
83
+ # Supports standard HTML select objects and Chosen select objects.
84
+ #
85
+ # @return [Integer]
86
+ # @example
87
+ # num_colors = color_select.get_option_count
88
+ #
89
+ def get_option_count
90
+ obj, = find_element
91
+ object_not_found_exception(obj, nil)
92
+ if first(:css, 'li.active-result')
93
+ obj.all('li.active-result').count
94
+ else
95
+ obj.all(@list_item).count
96
+ end
97
+ end
98
+
99
+ alias get_item_count get_option_count
100
+
101
+ def verify_options(expected, enqueue = false)
102
+ actual = get_options
103
+ enqueue ?
104
+ ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{object_ref_message}") :
105
+ assert_equal(expected, actual, "Expected list of options in list #{object_ref_message} to be #{expected} but found #{actual}")
106
+ end
107
+
108
+ # Return text of first selected option in a select box object.
109
+ # Supports standard HTML select objects and Chosen select objects.
110
+ #
111
+ # @return [String]
112
+ # @example
113
+ # current_color = color_select.get_selected_option
114
+ #
115
+ def get_selected_option
116
+ obj, = find_element
117
+ object_not_found_exception(obj, nil)
118
+ if first(:css, 'li.active-result')
119
+ obj.first("//li[contains(@class, 'result-selected')]").text
120
+ else
121
+ obj.first(@selected_item).text
122
+ end
123
+ end
124
+
125
+ alias selected? get_selected_option
126
+
127
+ # Select the specified option in a Siebel OUI select box object.
128
+ #
129
+ # @param option [String] text of option to select
130
+ # @example
131
+ # country_select.choose_siebel_option('Cayman Islands')
132
+ #
133
+ def choose_siebel_option(option)
134
+ Capybara.wait_on_first_by_default = true
135
+ invoke_siebel_popup
136
+ first(:xpath, "//li[@class='ui-menu-item']", :exact => true, :match => :prefer_exact, text: option).click
137
+ end
138
+
139
+ # Return array of strings of all options in a Siebel OUI select box object.
140
+ #
141
+ # @return [Array]
142
+ # @example
143
+ # all_countries = country_select.get_siebel_options
144
+ #
145
+ def get_siebel_options
146
+ invoke_siebel_popup
147
+ sleep(0.5)
148
+ options = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text)
149
+ obj, = find_element
150
+ obj.native.send_keys(:escape)
151
+ options
152
+ end
153
+
154
+ def verify_siebel_options(expected, enqueue = false)
155
+ invoke_siebel_popup
156
+ sleep(0.5)
157
+ actual = page.all(:xpath, "//li[@class='ui-menu-item']").collect(&:text)
158
+ enqueue ?
159
+ ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected list of options in list #{object_ref_message}") :
160
+ assert_equal(expected, actual, "Expected list of options in list #{object_ref_message} to be #{expected} but found #{actual}")
161
+ obj, = find_element
162
+ obj.native.send_keys(:escape)
163
+ end
164
+
165
+ # Is Siebel JComboBox set to read-only?
166
+ #
167
+ # @return [Boolean]
168
+ # @example
169
+ # country_select.read_only?
170
+ #
171
+ def read_only?
172
+ obj, = find_element
173
+ object_not_found_exception(obj, nil)
174
+ !obj.native.attribute('readonly')
175
+ end
176
+
177
+ private
178
+
179
+ def select_item(obj, option)
180
+ if option.is_a?(Hash)
181
+ obj.find("option[value='#{option[:value]}']").click if option.has_key?(:value)
182
+ obj.find(:xpath, "option[#{option[:index]}]").select_option if option.has_key?(:index)
183
+ obj.select option[:text] if option.has_key?(:text)
184
+ else
185
+ obj.select option
186
+ end
187
+ end
188
+ end
189
+ end