testcentricity 2.4.2 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +29 -0
  3. data/.rspec +2 -1
  4. data/.rubocop.yml +38 -0
  5. data/.ruby-version +1 -1
  6. data/.simplecov +9 -0
  7. data/.yardopts +3 -0
  8. data/CHANGELOG.md +275 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/{LICENSE.txt → LICENSE.md} +3 -4
  11. data/README.md +938 -1380
  12. data/Rakefile +63 -1
  13. data/config/cucumber.yml +145 -0
  14. data/config/locales/en-US.yml +56 -0
  15. data/config/test_data/LOCAL_data.yml +11 -0
  16. data/config/test_data/data.yml +10 -0
  17. data/features/deep_links.feature +26 -0
  18. data/features/login.feature +30 -0
  19. data/features/navigation.feature +31 -0
  20. data/features/step_definitions/generic_steps.rb +72 -0
  21. data/features/support/android/screens/about_screen.rb +11 -0
  22. data/features/support/android/screens/base_app_screen.rb +29 -0
  23. data/features/support/android/screens/checkout_address_screen.rb +17 -0
  24. data/features/support/android/screens/checkout_payment_screen.rb +22 -0
  25. data/features/support/android/screens/login_screen.rb +18 -0
  26. data/features/support/android/screens/products_screen.rb +13 -0
  27. data/features/support/android/screens/saucebot_screen.rb +16 -0
  28. data/features/support/android/screens/webview_screen.rb +13 -0
  29. data/features/support/android/sections/nav_widgets/nav_menu.rb +39 -0
  30. data/features/support/env.rb +61 -0
  31. data/features/support/hooks.rb +135 -0
  32. data/features/support/ios/screens/about_screen.rb +11 -0
  33. data/features/support/ios/screens/base_app_screen.rb +19 -0
  34. data/features/support/ios/screens/checkout_address_screen.rb +17 -0
  35. data/features/support/ios/screens/checkout_payment_screen.rb +22 -0
  36. data/features/support/ios/screens/login_screen.rb +18 -0
  37. data/features/support/ios/screens/products_screen.rb +13 -0
  38. data/features/support/ios/screens/saucebot_screen.rb +16 -0
  39. data/features/support/ios/screens/webview_screen.rb +13 -0
  40. data/features/support/ios/sections/list_items/product_cell_item.rb +13 -0
  41. data/features/support/ios/sections/modals/base_modal.rb +23 -0
  42. data/features/support/ios/sections/modals/logout_modal.rb +6 -0
  43. data/features/support/ios/sections/modals/reset_app_state_modal.rb +6 -0
  44. data/features/support/ios/sections/nav_widgets/nav_bar.rb +31 -0
  45. data/features/support/ios/sections/nav_widgets/nav_menu.rb +41 -0
  46. data/features/support/shared_components/screens/base_app_screen.rb +31 -0
  47. data/features/support/shared_components/screens/checkout_address_screen.rb +17 -0
  48. data/features/support/shared_components/screens/checkout_payment_screen.rb +22 -0
  49. data/features/support/shared_components/screens/login_screen.rb +39 -0
  50. data/features/support/shared_components/screens/saucebot_screen.rb +17 -0
  51. data/features/support/shared_components/screens/webview_screen.rb +12 -0
  52. data/features/support/shared_components/sections/nav_menu.rb +58 -0
  53. data/features/support/world_data.rb +12 -0
  54. data/features/support/world_pages.rb +26 -0
  55. data/lib/testcentricity/app_core/appium_connect_helper.rb +343 -111
  56. data/lib/testcentricity/app_core/screen_object.rb +252 -0
  57. data/lib/testcentricity/app_core/screen_objects_helper.rb +29 -201
  58. data/lib/testcentricity/app_core/{screen_sections_helper.rb → screen_section.rb} +40 -105
  59. data/lib/testcentricity/app_elements/app_element_helper.rb +17 -8
  60. data/lib/testcentricity/app_elements/checkbox.rb +3 -3
  61. data/lib/testcentricity/data_objects/environment.rb +133 -39
  62. data/lib/testcentricity/version.rb +1 -1
  63. data/lib/testcentricity.rb +4 -129
  64. data/reports/.keep +1 -0
  65. data/spec/fixtures/page_object.rb +22 -0
  66. data/spec/fixtures/page_section_object.rb +21 -0
  67. data/spec/fixtures/screen_object.rb +16 -0
  68. data/spec/fixtures/screen_section_object.rb +16 -0
  69. data/spec/spec_helper.rb +28 -9
  70. data/spec/testcentricity/elements/button_spec.rb +18 -0
  71. data/spec/testcentricity/elements/checkbox_spec.rb +28 -0
  72. data/spec/testcentricity/elements/image_spec.rb +13 -0
  73. data/spec/testcentricity/elements/label_spec.rb +18 -0
  74. data/spec/testcentricity/elements/list_spec.rb +13 -0
  75. data/spec/testcentricity/elements/ui_element_spec.rb +72 -0
  76. data/spec/testcentricity/mobile/appium_connect_spec.rb +117 -0
  77. data/spec/testcentricity/mobile/screen_object_spec.rb +63 -0
  78. data/spec/testcentricity/mobile/screen_section_object_spec.rb +56 -0
  79. data/spec/testcentricity/version_spec.rb +7 -0
  80. data/spec/testcentricity/web/browser_spec.rb +41 -0
  81. data/spec/testcentricity/web/local_webdriver_spec.rb +86 -0
  82. data/spec/testcentricity/web/mobile_webdriver_spec.rb +123 -0
  83. data/spec/testcentricity/web/page_object_spec.rb +85 -0
  84. data/spec/testcentricity/web/page_section_object_spec.rb +72 -0
  85. data/testcentricity.gemspec +28 -27
  86. metadata +196 -127
  87. data/.ruby-gemset +0 -1
  88. data/Gemfile.lock +0 -93
  89. data/bin/console +0 -14
  90. data/bin/setup +0 -8
  91. data/lib/devices/devices.yml +0 -352
  92. data/lib/testcentricity/app_core/appium_server.rb +0 -69
  93. data/lib/testcentricity/browser_helper.rb +0 -174
  94. data/lib/testcentricity/data_objects/data_objects_helper.rb +0 -78
  95. data/lib/testcentricity/data_objects/excel_helper.rb +0 -242
  96. data/lib/testcentricity/exception_queue_helper.rb +0 -111
  97. data/lib/testcentricity/utility_helpers.rb +0 -28
  98. data/lib/testcentricity/web_core/drag_drop_helper.rb +0 -15
  99. data/lib/testcentricity/web_core/page_objects_helper.rb +0 -677
  100. data/lib/testcentricity/web_core/page_sections_helper.rb +0 -895
  101. data/lib/testcentricity/web_core/webdriver_helper.rb +0 -588
  102. data/lib/testcentricity/web_elements/button.rb +0 -8
  103. data/lib/testcentricity/web_elements/cell_button.rb +0 -8
  104. data/lib/testcentricity/web_elements/cell_checkbox.rb +0 -38
  105. data/lib/testcentricity/web_elements/cell_element.rb +0 -69
  106. data/lib/testcentricity/web_elements/cell_image.rb +0 -8
  107. data/lib/testcentricity/web_elements/cell_radio.rb +0 -31
  108. data/lib/testcentricity/web_elements/checkbox.rb +0 -100
  109. data/lib/testcentricity/web_elements/file_field.rb +0 -45
  110. data/lib/testcentricity/web_elements/image.rb +0 -34
  111. data/lib/testcentricity/web_elements/label.rb +0 -8
  112. data/lib/testcentricity/web_elements/link.rb +0 -8
  113. data/lib/testcentricity/web_elements/list.rb +0 -100
  114. data/lib/testcentricity/web_elements/list_button.rb +0 -8
  115. data/lib/testcentricity/web_elements/list_checkbox.rb +0 -38
  116. data/lib/testcentricity/web_elements/list_element.rb +0 -61
  117. data/lib/testcentricity/web_elements/list_radio.rb +0 -31
  118. data/lib/testcentricity/web_elements/radio.rb +0 -74
  119. data/lib/testcentricity/web_elements/select_list.rb +0 -208
  120. data/lib/testcentricity/web_elements/siebel_open_ui_helper.rb +0 -15
  121. data/lib/testcentricity/web_elements/table.rb +0 -612
  122. data/lib/testcentricity/web_elements/textfield.rb +0 -114
  123. data/lib/testcentricity/web_elements/ui_elements_helper.rb +0 -532
  124. data/lib/testcentricity/world_extensions.rb +0 -26
  125. data/my_templates/default/method_details/setup.rb +0 -3
  126. data/spec/testcentricity_spec.rb +0 -9
@@ -1,114 +0,0 @@
1
- module TestCentricity
2
- class TextField < UIElement
3
- def initialize(name, parent, locator, context)
4
- super
5
- @type = :textfield
6
- end
7
-
8
- # Is text field set to read-only?
9
- #
10
- # @return [Boolean]
11
- # @example
12
- # comments_field.read_only?
13
- #
14
- def read_only?
15
- obj, = find_element
16
- object_not_found_exception(obj, nil)
17
- !!obj.native.attribute('readonly')
18
- end
19
-
20
- # Return maxlength character count of a text field.
21
- #
22
- # @return [Integer]
23
- # @example
24
- # max_num_chars = comments_field.get_max_length
25
- #
26
- def get_max_length
27
- obj, = find_element
28
- object_not_found_exception(obj, nil)
29
- max_length = obj.native.attribute('maxlength')
30
- max_length.to_i unless max_length.blank?
31
- end
32
-
33
- # Return placeholder text of a text field.
34
- #
35
- # @return [String]
36
- # @example
37
- # placeholder_message = username_field.get_placeholder
38
- #
39
- def get_placeholder
40
- obj, = find_element
41
- object_not_found_exception(obj, nil)
42
- obj.native.attribute('placeholder')
43
- end
44
-
45
- # Return min attribute of a number type text field.
46
- #
47
- # @return [Integer]
48
- # @example
49
- # min_points_value = points_field.get_min
50
- #
51
- def get_min
52
- obj, = find_element
53
- object_not_found_exception(obj, nil)
54
- min = obj.native.attribute('min')
55
- min.to_i unless min.blank?
56
- end
57
-
58
- # Return max attribute of a number type text field.
59
- #
60
- # @return [Integer]
61
- # @example
62
- # max_points_value = points_field.get_max
63
- #
64
- def get_max
65
- obj, = find_element
66
- object_not_found_exception(obj, nil)
67
- max = obj.native.attribute('max')
68
- max.to_i unless max.blank?
69
- end
70
-
71
- # Return step attribute of a number type text field.
72
- #
73
- # @return [Integer]
74
- # @example
75
- # points_step = points_field.get_step
76
- #
77
- def get_step
78
- obj, = find_element
79
- object_not_found_exception(obj, nil)
80
- step = obj.native.attribute('step')
81
- step.to_i unless step.blank?
82
- end
83
-
84
- # Clear the contents of a text field
85
- #
86
- # @example
87
- # first_name_field.clear
88
- #
89
- def clear
90
- case get_native_attribute('tagName').downcase.to_sym
91
- when :textarea
92
- set('')
93
- sleep(0.5)
94
- send_keys(:tab)
95
- when :div
96
- set('')
97
- else
98
- length = get_value.length
99
- length.times do
100
- send_keys(:backspace)
101
- end
102
- sleep(0.5)
103
- send_keys(:tab)
104
- sleep(0.5)
105
- length = get_value.length
106
- if length > 0
107
- set('')
108
- sleep(0.5)
109
- send_keys(:tab)
110
- end
111
- end
112
- end
113
- end
114
- end
@@ -1,532 +0,0 @@
1
- require 'test/unit'
2
-
3
- Capybara::Node::Element.class_eval do
4
- def click_at(x, y)
5
- right = x - (native.size.width / 2)
6
- top = y - (native.size.height / 2)
7
- driver.browser.action.move_to(native).move_by(right.to_i, top.to_i).click.perform
8
- end
9
-
10
- def get_width
11
- native.size.width
12
- end
13
-
14
- def get_height
15
- native.size.height
16
- end
17
-
18
- def get_x
19
- native.location.x
20
- end
21
-
22
- def get_y
23
- native.location.y
24
- end
25
-
26
- def displayed?
27
- native.displayed?
28
- end
29
- end
30
-
31
-
32
- module TestCentricity
33
- class UIElement
34
- include Capybara::DSL
35
- include Test::Unit::Assertions
36
-
37
- attr_reader :parent, :locator, :context, :type, :name
38
- attr_accessor :alt_locator, :locator_type
39
-
40
- XPATH_SELECTORS = ['//', '[@', '[contains(@']
41
- CSS_SELECTORS = ['#', ':nth-child(', ':nth-of-type(', '^=', '$=', '*=']
42
-
43
- def initialize(name, parent, locator, context)
44
- @name = name
45
- @parent = parent
46
- @locator = locator
47
- @context = context
48
- @type = nil
49
- @alt_locator = nil
50
- set_locator_type
51
- end
52
-
53
- def set_locator_type(locator = nil)
54
- locator = @locator if locator.nil?
55
- is_xpath = XPATH_SELECTORS.any? { |selector| locator.include?(selector) }
56
- is_css = CSS_SELECTORS.any? { |selector| locator.include?(selector) }
57
- if is_xpath && !is_css
58
- @locator_type = :xpath
59
- elsif is_css && !is_xpath
60
- @locator_type = :css
61
- elsif !is_css && !is_xpath
62
- @locator_type = :css
63
- else
64
- raise "Cannot determine type of locator for UIElement '#{@name}' - locator = #{locator}"
65
- end
66
- end
67
-
68
- def get_object_type
69
- if @type
70
- @type
71
- else
72
- obj, type = find_element
73
- object_not_found_exception(obj, type)
74
- if obj.tag_name
75
- obj.tag_name
76
- elsif obj.native.attribute('type')
77
- obj.native.attribute('type')
78
- end
79
- end
80
- end
81
-
82
- def get_locator
83
- @locator
84
- end
85
-
86
- def get_name
87
- @name
88
- end
89
-
90
- def set_alt_locator(temp_locator)
91
- @alt_locator = temp_locator
92
- end
93
-
94
- def clear_alt_locator
95
- @alt_locator = nil
96
- end
97
-
98
- # Click on an object
99
- #
100
- # @example
101
- # basket_link.click
102
- #
103
- def click
104
- obj, type = find_element
105
- object_not_found_exception(obj, type)
106
- begin
107
- obj.click
108
- rescue
109
- obj.click_at(10, 10) unless Capybara.current_driver == :poltergeist
110
- end
111
- end
112
-
113
- # Double-click on an object
114
- #
115
- # @example
116
- # file_image.double_click
117
- #
118
- def double_click
119
- obj, type = find_element
120
- object_not_found_exception(obj, type)
121
- page.driver.browser.action.double_click(obj.native).perform
122
- end
123
-
124
- # Right-click on an object
125
- #
126
- # @example
127
- # basket_item_image.right_click
128
- #
129
- def right_click
130
- obj, type = find_element
131
- object_not_found_exception(obj, type)
132
- page.driver.browser.action.context_click(obj.native).perform
133
- end
134
-
135
- # Click at a specific location within an object
136
- #
137
- # @param x [Integer] X offset
138
- # @param y [Integer] Y offset
139
- # @example
140
- # basket_item_image.click_at(10, 10)
141
- #
142
- def click_at(x, y)
143
- obj, = find_element
144
- raise "UI #{object_ref_message} not found" unless obj
145
- obj.click_at(x, y)
146
- end
147
-
148
- def set(value)
149
- obj, type = find_element
150
- object_not_found_exception(obj, type)
151
- obj.set(value)
152
- end
153
-
154
- # Send keystrokes to this object.
155
- #
156
- # @param keys [String] keys
157
- # @example
158
- # comment_field.send_keys(:enter)
159
- #
160
- def send_keys(*keys)
161
- obj, type = find_element
162
- object_not_found_exception(obj, type)
163
- obj.send_keys(*keys)
164
- end
165
-
166
- # Does UI object exists?
167
- #
168
- # @return [Boolean]
169
- # @example
170
- # basket_link.exists?
171
- #
172
- def exists?(visible = true)
173
- obj, = find_object(visible)
174
- obj != nil
175
- end
176
-
177
- # Is UI object visible?
178
- #
179
- # @return [Boolean]
180
- # @example
181
- # remember_me_checkbox.visible?
182
- #
183
- def visible?
184
- obj, type = find_object
185
- exists = obj
186
- invisible = false
187
- if type == :css
188
- Capybara.using_wait_time 0.1 do
189
- # is object itself hidden with .ui-helper-hidden class?
190
- self_hidden = page.has_css?("#{@locator}.ui-helper-hidden")
191
- # is parent of object hidden, thus hiding the object?
192
- parent_hidden = page.has_css?(".ui-helper-hidden > #{@locator}")
193
- # is grandparent of object, or any other ancestor, hidden?
194
- other_ancestor_hidden = page.has_css?(".ui-helper-hidden * #{@locator}")
195
- # if any of the above conditions are true, then object is invisible
196
- invisible = self_hidden || parent_hidden || other_ancestor_hidden
197
- end
198
- else
199
- invisible = !obj.visible? if exists
200
- end
201
- # the object is visible if it exists and it is not invisible
202
- if exists && !invisible
203
- true
204
- else
205
- false
206
- end
207
- end
208
-
209
- # Is UI object hidden (not visible)?
210
- #
211
- # @return [Boolean]
212
- # @example
213
- # remember_me_checkbox.hidden?
214
- #
215
- def hidden?
216
- !visible?
217
- end
218
-
219
- # Is UI object enabled?
220
- #
221
- # @return [Boolean]
222
- # @example
223
- # login_button.enabled?
224
- #
225
- def enabled?
226
- !disabled?
227
- end
228
-
229
- # Is UI object disabled (not enabled)?
230
- #
231
- # @return [Boolean]
232
- # @example
233
- # login_button.disabled?
234
- #
235
- def disabled?
236
- obj, type = find_element
237
- object_not_found_exception(obj, type)
238
- obj.disabled?
239
- end
240
-
241
- # Wait until the object exists, or until the specified wait time has expired. If the wait time is nil, then the wait
242
- # time will be Capybara.default_max_wait_time.
243
- #
244
- # @param seconds [Integer or Float] wait time in seconds
245
- # @example
246
- # run_button.wait_until_exists(0.5)
247
- #
248
- def wait_until_exists(seconds = nil)
249
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
250
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
251
- wait.until { exists? }
252
- rescue
253
- raise "Could not find UI #{object_ref_message} after #{timeout} seconds" unless exists?
254
- end
255
-
256
- # Wait until the object no longer exists, or until the specified wait time has expired. If the wait time is nil, then
257
- # the wait time will be Capybara.default_max_wait_time.
258
- #
259
- # @param seconds [Integer or Float] wait time in seconds
260
- # @example
261
- # logout_button.wait_until_gone(5)
262
- #
263
- def wait_until_gone(seconds = nil)
264
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
265
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
266
- wait.until { !exists? }
267
- rescue
268
- raise "UI #{object_ref_message} remained visible after #{timeout} seconds" if exists?
269
- end
270
-
271
- # Wait until the object is visible, or until the specified wait time has expired. If the wait time is nil, then the
272
- # wait time will be Capybara.default_max_wait_time.
273
- #
274
- # @param seconds [Integer or Float] wait time in seconds
275
- # @example
276
- # run_button.wait_until_visible(0.5)
277
- #
278
- def wait_until_visible(seconds = nil)
279
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
280
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
281
- wait.until { visible? }
282
- rescue
283
- raise "Could not find UI #{object_ref_message} after #{timeout} seconds" unless visible?
284
- end
285
-
286
- # Wait until the object is hidden, or until the specified wait time has expired. If the wait time is nil, then the
287
- # wait time will be Capybara.default_max_wait_time.
288
- #
289
- # @param seconds [Integer or Float] wait time in seconds
290
- # @example
291
- # run_button.wait_until_hidden(10)
292
- #
293
- def wait_until_hidden(seconds = nil)
294
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
295
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
296
- wait.until { hidden? }
297
- rescue
298
- raise "UI #{object_ref_message} remained visible after #{timeout} seconds" if visible?
299
- end
300
-
301
- # Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait
302
- # time is nil, then the wait time will be Capybara.default_max_wait_time.
303
- #
304
- # @param value [String or Hash] value expected or comparison hash
305
- # @param seconds [Integer or Float] wait time in seconds
306
- # @example
307
- # card_authorized_label.wait_until_value_is('Card authorized', 5)
308
- # or
309
- # total_weight_field.wait_until_value_is({ :greater_than => '250' }, 5)
310
- #
311
- def wait_until_value_is(value, seconds = nil)
312
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
313
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
314
- wait.until { compare(value, get_value) }
315
- rescue
316
- raise "Value of UI #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
317
- end
318
-
319
- # Wait until the object's value changes to a different value, or until the specified wait time has expired. If the
320
- # wait time is nil, then the wait time will be Capybara.default_max_wait_time.
321
- #
322
- # @param seconds [Integer or Float] wait time in seconds
323
- # @example
324
- # basket_grand_total_label.wait_until_value_changes(5)
325
- #
326
- def wait_until_value_changes(seconds = nil)
327
- value = get_value
328
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
329
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
330
- wait.until { get_value != value }
331
- rescue
332
- raise "Value of UI #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_value == value
333
- end
334
-
335
- # Return width of object.
336
- #
337
- # @return [Integer]
338
- # @example
339
- # button_width = my_button.width
340
- #
341
- def width
342
- obj, type = find_element(false)
343
- object_not_found_exception(obj, type)
344
- obj.get_width
345
- end
346
-
347
- # Return height of object.
348
- #
349
- # @return [Integer]
350
- # @example
351
- # button_height = my_button.height
352
- #
353
- def height
354
- obj, type = find_element(false)
355
- object_not_found_exception(obj, type)
356
- obj.get_height
357
- end
358
-
359
- # Return x coordinate of object's location.
360
- #
361
- # @return [Integer]
362
- # @example
363
- # button_x = my_button.x
364
- #
365
- def x
366
- obj, type = find_element(false)
367
- object_not_found_exception(obj, type)
368
- obj.get_x
369
- end
370
-
371
- # Return y coordinate of object's location.
372
- #
373
- # @return [Integer]
374
- # @example
375
- # button_y = my_button.y
376
- #
377
- def y
378
- obj, type = find_element(false)
379
- object_not_found_exception(obj, type)
380
- obj.get_y
381
- end
382
-
383
- # Is UI object displayed in browser window?
384
- #
385
- # @return [Boolean]
386
- # @example
387
- # basket_link.displayed??
388
- #
389
- def displayed?
390
- obj, type = find_element(false)
391
- object_not_found_exception(obj, type)
392
- obj.displayed?
393
- end
394
-
395
- def get_value(visible = true)
396
- obj, type = find_element(visible)
397
- object_not_found_exception(obj, type)
398
- case obj.tag_name.downcase
399
- when 'input', 'select', 'textarea'
400
- obj.value
401
- else
402
- obj.text
403
- end
404
- end
405
-
406
- alias get_caption get_value
407
-
408
- def verify_value(expected, enqueue = false)
409
- actual = get_value
410
- enqueue ?
411
- ExceptionQueue.enqueue_assert_equal(expected.strip, actual.strip, "Expected UI #{object_ref_message}") :
412
- assert_equal(expected.strip, actual.strip, "Expected UI #{object_ref_message} to display '#{expected}' but found '#{actual}'")
413
- end
414
-
415
- alias verify_caption verify_value
416
-
417
- # Hover the cursor over an object
418
- #
419
- # @example
420
- # basket_link.hover
421
- #
422
- def hover
423
- obj, type = find_element
424
- object_not_found_exception(obj, type)
425
- obj.hover
426
- end
427
-
428
- def drag_by(right_offset, down_offset)
429
- obj, type = find_element
430
- object_not_found_exception(obj, type)
431
- page.driver.browser.action.click_and_hold(obj.native).perform
432
- sleep(1)
433
- obj.drag_by(right_offset, down_offset)
434
- end
435
-
436
- def drag_and_drop(target, right_offset = nil, down_offset = nil)
437
- source, type = find_element
438
- object_not_found_exception(source, type)
439
- page.driver.browser.action.click_and_hold(source.native).perform
440
- sleep(1)
441
- target_drop, = target.find_element
442
- page.driver.browser.action.move_to(target_drop.native, right_offset.to_i, down_offset.to_i).release.perform
443
- end
444
-
445
- def get_attribute(attrib)
446
- obj, type = find_element(false)
447
- object_not_found_exception(obj, type)
448
- obj[attrib]
449
- end
450
-
451
- def get_native_attribute(attrib)
452
- obj, type = find_element(false)
453
- object_not_found_exception(obj, type)
454
- obj.native.attribute(attrib)
455
- end
456
-
457
- private
458
-
459
- def find_element(visible = true)
460
- wait = Selenium::WebDriver::Wait.new(timeout: Capybara.default_max_wait_time)
461
- wait.until { find_object(visible) }
462
- end
463
-
464
- def find_object(visible = true)
465
- @alt_locator.nil? ? obj_locator = @locator : obj_locator = @alt_locator
466
- parent_section = @context == :section && !@parent.get_locator.nil?
467
- parent_section ? tries ||= 2 : tries ||= 1
468
-
469
- if parent_section && tries > 1
470
- parent_locator = @parent.get_locator
471
- parent_locator = parent_locator.gsub('|', ' ')
472
- parent_locator_type = @parent.get_locator_type
473
- obj = page.find(parent_locator_type, parent_locator, :wait => 0.01).find(@locator_type, obj_locator, :wait => 0.01, :visible => visible)
474
- else
475
- obj = page.find(@locator_type, obj_locator, :wait => 0.01, :visible => visible)
476
- end
477
- [obj, @locator_type]
478
- rescue
479
- retry if (tries -= 1) > 0
480
- [nil, nil]
481
- end
482
-
483
- def object_not_found_exception(obj, obj_type)
484
- @alt_locator.nil? ? locator = @locator : locator = @alt_locator
485
- obj_type.nil? ? object_type = 'Object' : object_type = obj_type
486
- raise ObjectNotFoundError.new("#{object_type} named '#{@name}' (#{locator}) not found") unless obj
487
- end
488
-
489
- def invalid_object_type_exception(obj, obj_type)
490
- unless obj.tag_name == obj_type || obj.native.attribute('type') == obj_type
491
- @alt_locator.nil? ? locator = @locator : locator = @alt_locator
492
- raise "#{locator} is not a #{obj_type} element"
493
- end
494
- end
495
-
496
- def invoke_siebel_popup
497
- obj, = find_element
498
- object_not_found_exception(obj, 'Siebel object')
499
- trigger_name = obj.native.attribute('aria-describedby').strip
500
- trigger = "span##{trigger_name}"
501
- trigger = "#{@parent.get_locator} #{trigger}" if @context == :section && !@parent.get_locator.nil?
502
- first(trigger).click
503
- end
504
-
505
- def object_ref_message
506
- "object '#{get_name}' (#{get_locator})"
507
- end
508
-
509
- def compare(expected, actual)
510
- if expected.is_a?(Hash)
511
- result = false
512
- expected.each do |key, value|
513
- case key
514
- when :lt, :less_than
515
- result = actual < value
516
- when :lt_eq, :less_than_or_equal
517
- result = actual <= value
518
- when :gt, :greater_than
519
- result = actual > value
520
- when :gt_eq, :greater_than_or_equal
521
- result = actual >= value
522
- when :not_equal
523
- result = actual != value
524
- end
525
- end
526
- else
527
- result = expected == actual
528
- end
529
- result
530
- end
531
- end
532
- end
@@ -1,26 +0,0 @@
1
- module WorldData
2
- def environs
3
- @environs ||= TestCentricity::EnvironData.new
4
- end
5
-
6
- # instantiate and register all data objects specified in data_objects method
7
- def instantiate_data_objects
8
- # return if data objects have already been instantiated and registered
9
- return if TestCentricity::DataManager.loaded?
10
-
11
- # register and instantiate all data objects
12
- eval(TestCentricity::DataManager.register_data_objects(data_objects))
13
- end
14
- end
15
-
16
-
17
- module WorldPages
18
- # instantiate and register all page objects specified in page_objects method
19
- def instantiate_page_objects
20
- # return if page objects have already been instantiated and registered
21
- return if TestCentricity::PageManager.loaded?
22
-
23
- # register and instantiate all page objects
24
- eval(TestCentricity::PageManager.register_page_objects(page_objects))
25
- end
26
- end
@@ -1,3 +0,0 @@
1
- def source
2
- return
3
- end
@@ -1,9 +0,0 @@
1
- RSpec.describe Testcentricity do
2
- it "has a version number" do
3
- expect(Testcentricity::VERSION).not_to be nil
4
- end
5
-
6
- it "does something useful" do
7
- expect(false).to eq(true)
8
- end
9
- end