testcentricity_web 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. metadata +3 -52
  3. data/.gitignore +0 -27
  4. data/.rubocop.yml +0 -41
  5. data/.yardopts +0 -2
  6. data/Gemfile +0 -6
  7. data/LICENSE.txt +0 -28
  8. data/README.md +0 -1434
  9. data/Rakefile +0 -1
  10. data/lib/devices/devices.yml +0 -280
  11. data/lib/testcentricity_web.rb +0 -140
  12. data/lib/testcentricity_web/browser_helper.rb +0 -173
  13. data/lib/testcentricity_web/data_objects_helper.rb +0 -78
  14. data/lib/testcentricity_web/drag_drop_helper.rb +0 -15
  15. data/lib/testcentricity_web/elements/button.rb +0 -8
  16. data/lib/testcentricity_web/elements/cell_button.rb +0 -8
  17. data/lib/testcentricity_web/elements/cell_checkbox.rb +0 -38
  18. data/lib/testcentricity_web/elements/cell_element.rb +0 -62
  19. data/lib/testcentricity_web/elements/cell_image.rb +0 -8
  20. data/lib/testcentricity_web/elements/cell_radio.rb +0 -31
  21. data/lib/testcentricity_web/elements/checkbox.rb +0 -99
  22. data/lib/testcentricity_web/elements/file_field.rb +0 -45
  23. data/lib/testcentricity_web/elements/image.rb +0 -34
  24. data/lib/testcentricity_web/elements/label.rb +0 -8
  25. data/lib/testcentricity_web/elements/link.rb +0 -8
  26. data/lib/testcentricity_web/elements/list.rb +0 -54
  27. data/lib/testcentricity_web/elements/list_button.rb +0 -8
  28. data/lib/testcentricity_web/elements/list_checkbox.rb +0 -38
  29. data/lib/testcentricity_web/elements/list_element.rb +0 -51
  30. data/lib/testcentricity_web/elements/list_radio.rb +0 -31
  31. data/lib/testcentricity_web/elements/radio.rb +0 -73
  32. data/lib/testcentricity_web/elements/select_list.rb +0 -189
  33. data/lib/testcentricity_web/elements/table.rb +0 -473
  34. data/lib/testcentricity_web/elements/textfield.rb +0 -84
  35. data/lib/testcentricity_web/environment.rb +0 -249
  36. data/lib/testcentricity_web/excel_helper.rb +0 -242
  37. data/lib/testcentricity_web/exception_queue_helper.rb +0 -47
  38. data/lib/testcentricity_web/page_objects_helper.rb +0 -656
  39. data/lib/testcentricity_web/page_sections_helper.rb +0 -805
  40. data/lib/testcentricity_web/siebel_open_ui_helper.rb +0 -15
  41. data/lib/testcentricity_web/ui_elements_helper.rb +0 -425
  42. data/lib/testcentricity_web/utility_helpers.rb +0 -28
  43. data/lib/testcentricity_web/version.rb +0 -3
  44. data/lib/testcentricity_web/webdriver_helper.rb +0 -451
  45. data/lib/testcentricity_web/world_extensions.rb +0 -26
  46. data/testcentricity_web.gemspec +0 -42
@@ -1,805 +0,0 @@
1
- require 'test/unit'
2
-
3
- module TestCentricity
4
- class PageSection
5
- include Capybara::DSL
6
- include Capybara::Node::Matchers
7
- include Test::Unit::Assertions
8
-
9
- attr_reader :context, :name
10
- attr_accessor :locator
11
- attr_accessor :parent
12
- attr_accessor :parent_list
13
- attr_accessor :list_index
14
-
15
-
16
- def initialize(name, parent, locator, context)
17
- @name = name
18
- @parent = parent
19
- @locator = locator
20
- @context = context
21
- @parent_list = nil
22
- @list_index = nil
23
- end
24
-
25
- def get_locator
26
- if @locator.empty? && defined?(section_locator)
27
- locator = section_locator
28
- else
29
- locator = @locator
30
- end
31
-
32
- unless @parent_list.nil?
33
- locator = "#{@parent_list.get_locator}|#{locator}"
34
- unless @list_index.nil?
35
- if locator.include?('/')
36
- locator = "(#{locator})[#{@list_index}]"
37
- else
38
- locator = "#{locator}:nth-of-type(#{@list_index})"
39
- end
40
- end
41
- end
42
-
43
- if @context == :section && !@parent.nil? && !@parent.get_locator.nil?
44
- "#{@parent.get_locator}|#{locator}"
45
- else
46
- locator
47
- end
48
- end
49
-
50
- def set_list_index(list, index = 1)
51
- @parent_list = list unless list.nil?
52
- @list_index = index
53
- end
54
-
55
- def get_item_count
56
- raise 'No parent list defined' if @parent_list.nil?
57
- @parent_list.get_item_count
58
- end
59
-
60
- def get_list_items
61
- items = []
62
- (1..get_item_count).each do |item|
63
- set_list_index(nil, item)
64
- items.push(get_value)
65
- end
66
- items
67
- end
68
-
69
- def get_object_type
70
- :section
71
- end
72
-
73
- def get_name
74
- @name
75
- end
76
-
77
- def set_parent(parent)
78
- @parent = parent
79
- end
80
-
81
- # Define a trait for this page section.
82
- #
83
- # @param trait_name [Symbol] name of trait (as a symbol)
84
- # @param block [&block] trait value
85
- # @example
86
- # trait(:section_locator) { "//div[@class='Messaging_Applet']" }
87
- # trait(:list_table_name) { '#Messages' }
88
- #
89
- def self.trait(trait_name, &block)
90
- define_method(trait_name.to_s, &block)
91
- end
92
-
93
- # Declare and instantiate a single generic UI Element for this page section.
94
- #
95
- # @param element_name [Symbol] name of UI object (as a symbol)
96
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
97
- # @example
98
- # element :undo_record_item, "//li[@rn='Undo Record']/a"
99
- # element :basket_header, 'div.basket_header'
100
- #
101
- def self.element(element_name, locator)
102
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::UIElement.new("#{element_name}", self, "#{locator}", :section);end))
103
- end
104
-
105
- # Declare and instantiate a collection of generic UI Elements for this page section.
106
- #
107
- # @param element_hash [Hash] names of UI objects (as a symbol) and CSS selectors or XPath expressions that uniquely identifies objects
108
- # @example
109
- # elements profile_item: 'a#profile',
110
- # settings_item: 'a#userPreferencesTrigger',
111
- # log_out_item: 'a#logout'
112
- #
113
- def self.elements(element_hash)
114
- element_hash.each do |element_name, locator|
115
- element(element_name, locator)
116
- end
117
- end
118
-
119
- # Declare and instantiate a single button UI Element for this page section.
120
- #
121
- # @param element_name [Symbol] name of button object (as a symbol)
122
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
123
- # @example
124
- # button :checkout_button, 'button.checkout_button'
125
- # button :login_button, "//input[@id='submit_button']"
126
- #
127
- def self.button(element_name, locator)
128
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Button.new("#{element_name}", self, "#{locator}", :section);end))
129
- end
130
-
131
- # Declare and instantiate a collection of buttons for this page section.
132
- #
133
- # @param element_hash [Hash] names of buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies buttons
134
- # @example
135
- # buttons new_account_button: 'button#new-account',
136
- # save_button: 'button#save',
137
- # cancel_button: 'button#cancel'
138
- #
139
- def self.buttons(element_hash)
140
- element_hash.each do |element_name, locator|
141
- button(element_name, locator)
142
- end
143
- end
144
-
145
- # Declare and instantiate a single text field UI Element for this page section.
146
- #
147
- # @param element_name [Symbol] name of text field object (as a symbol)
148
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
149
- # @example
150
- # textfield :user_id_field, "//input[@id='UserName']"
151
- # textfield :password_field, 'input#consumer_password'
152
- #
153
- def self.textfield(element_name, locator)
154
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::TextField.new("#{element_name}", self, "#{locator}", :section);end))
155
- end
156
-
157
- # Declare and instantiate a collection of text fields for this page section.
158
- #
159
- # @param element_hash [Hash] names of text fields (as a symbol) and CSS selectors or XPath expressions that uniquely identifies text fields
160
- # @example
161
- # textfields name_field: 'input#Name',
162
- # title_field: 'input#Title',
163
- # phone_field: 'input#PhoneNumber',
164
- # fax_field: 'input#FaxNumber',
165
- # email_field: 'input#Email'
166
- #
167
- def self.textfields(element_hash)
168
- element_hash.each do |element_name, locator|
169
- textfield(element_name, locator)
170
- end
171
- end
172
-
173
- # Declare and instantiate a single checkbox UI Element for this page section.
174
- #
175
- # @param element_name [Symbol] name of checkbox object (as a symbol)
176
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
177
- # @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
178
- # @example
179
- # checkbox :remember_checkbox, "//input[@id='RememberUser']"
180
- # checkbox :accept_terms_checkbox, 'input#accept_terms_conditions', :accept_terms_label
181
- #
182
- def self.checkbox(element_name, locator, proxy = nil)
183
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CheckBox.new("#{element_name}", self, "#{locator}", :section, #{proxy});end))
184
- end
185
-
186
- # Declare and instantiate a collection of checkboxes for this page section.
187
- #
188
- # @param element_hash [Hash] names of checkboxes (as a symbol) and CSS selectors or XPath expressions that uniquely identifies checkboxes
189
- # @example
190
- # checkboxes hazmat_certified_check: 'input#hazmatCertified',
191
- # epa_certified_check: 'input#epaCertified',
192
- # dhs_certified_check: 'input#homelandSecurityCertified',
193
- # carb_compliant_check: 'input#carbCompliant'
194
- #
195
- def self.checkboxes(element_hash)
196
- element_hash.each do |element_name, locator|
197
- checkbox(element_name, locator)
198
- end
199
- end
200
-
201
- # Declare and instantiate a single radio button UI Element for this page section.
202
- #
203
- # @param element_name [Symbol] name of radio object (as a symbol)
204
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
205
- # @param proxy [Symbol] Optional name (as a symbol) of proxy object to receive click actions
206
- # @example
207
- # radio :accept_terms_radio, "//input[@id='Accept_Terms']"
208
- # radio :decline_terms_radio, 'input#decline_terms_conditions', :decline_terms_label
209
- #
210
- def self.radio(element_name, locator, proxy = nil)
211
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Radio.new("#{element_name}", self, "#{locator}", :section, #{proxy});end))
212
- end
213
-
214
- # Declare and instantiate a collection of radio buttons for this page section.
215
- #
216
- # @param element_hash [Hash] names of radio buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies radio buttons
217
- # @example
218
- # radios visa_radio: 'input#payWithVisa',
219
- # mastercard_radio: 'input#payWithMastercard',
220
- # discover_radio: 'input#payWithDiscover',
221
- # amex_radio: 'input#payWithAmEx'
222
- #
223
- def self.radios(element_hash)
224
- element_hash.each do |element_name, locator|
225
- radio(element_name, locator)
226
- end
227
- end
228
-
229
- # Declare and instantiate a single label UI Element for this page section.
230
- #
231
- # @param element_name [Symbol] name of label object (as a symbol)
232
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
233
- # @example
234
- # label :welcome_label, 'div.Welcome'
235
- # label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
236
- #
237
- def self.label(element_name, locator)
238
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Label.new("#{element_name}", self, "#{locator}", :section);end))
239
- end
240
-
241
- def self.labels(element_hash)
242
- element_hash.each do |element_name, locator|
243
- label(element_name, locator)
244
- end
245
- end
246
-
247
- # Declare and instantiate a single link UI Element for this page section.
248
- #
249
- # @param element_name [Symbol] name of link object (as a symbol)
250
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
251
- # @example
252
- # link :registration_link, 'a.account-nav__link.register'
253
- # link :shopping_basket_link, "//a[@href='shopping_basket']"
254
- #
255
- def self.link(element_name, locator)
256
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Link.new("#{element_name}", self, "#{locator}", :section);end))
257
- end
258
-
259
- def self.links(element_hash)
260
- element_hash.each do |element_name, locator|
261
- link(element_name, locator)
262
- end
263
- end
264
-
265
- # Declare and instantiate a single table UI Element for this page section.
266
- #
267
- # @param element_name [Symbol] name of table object (as a symbol)
268
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
269
- # @example
270
- # table :payments_table, "//table[@class='payments_table']"
271
- #
272
- def self.table(element_name, locator)
273
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Table.new("#{element_name}", self, "#{locator}", :section);end))
274
- end
275
-
276
- def self.tables(element_hash)
277
- element_hash.each do |element_name, locator|
278
- table(element_name, locator)
279
- end
280
- end
281
-
282
- # Declare and instantiate a single select list UI Element for this page section.
283
- #
284
- # @param element_name [Symbol] name of select list object (as a symbol)
285
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
286
- # @example
287
- # selectlist :category_selector, 'select#search_form_category_chosen'
288
- # selectlist :gender_select, "//select[@id='customer_gender']"
289
- #
290
- def self.selectlist(element_name, locator)
291
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::SelectList.new("#{element_name}", self, "#{locator}", :section);end))
292
- end
293
-
294
- def self.selectlists(element_hash)
295
- element_hash.each do |element_name, locator|
296
- selectlist(element_name, locator)
297
- end
298
- end
299
-
300
- # Declare and instantiate a single list UI Element for this page section.
301
- #
302
- # @param element_name [Symbol] name of list object (as a symbol)
303
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
304
- # @example
305
- # list :y_axis_list, 'g.y_axis'
306
- #
307
- def self.list(element_name, locator)
308
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::List.new("#{element_name}", self, "#{locator}", :section);end))
309
- end
310
-
311
- def self.lists(element_hash)
312
- element_hash.each do |element_name, locator|
313
- list(element_name, locator)
314
- end
315
- end
316
-
317
- # Declare and instantiate an single image UI Element for this page section.
318
- #
319
- # @param element_name [Symbol] name of image object (as a symbol)
320
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
321
- # @example
322
- # image :basket_item_image, 'div.product_image'
323
- # image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
324
- #
325
- def self.image(element_name, locator)
326
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::Image.new("#{element_name}", self, "#{locator}", :section);end))
327
- end
328
-
329
- def self.images(element_hash)
330
- element_hash.each do |element_name, locator|
331
- image(element_name, locator)
332
- end
333
- end
334
-
335
- # Declare and instantiate a single File Field UI Element for this page section.
336
- #
337
- # @param element_name [Symbol] name of file field object (as a symbol)
338
- # @param locator [String] CSS selector or XPath expression that uniquely identifies object
339
- # @example
340
- # filefield :attach_file, 's_SweFileName'
341
- #
342
- def self.filefield(element_name, locator)
343
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::FileField.new("#{element_name}", self, "#{locator}", :section);end))
344
- end
345
-
346
- def self.filefields(element_hash)
347
- element_hash.each do |element_name, locator|
348
- filefield(element_name, locator)
349
- end
350
- end
351
-
352
- # Declare and instantiate a cell button in a table column on this page section.
353
- #
354
- # @param element_name [Symbol] name of cell button object (as a symbol)
355
- # @param locator [String] XPath expression that uniquely identifies cell button within row and column of parent table object
356
- # @param table [Symbol] Name (as a symbol) of parent table object
357
- # @param column [Integer] 1-based index of table column that contains the cell button object
358
- # @example
359
- # cell_button :show_button, "a[@class='show']", :data_table, 5
360
- # cell_button :edit_button, "a[@class='edit']", :data_table, 5
361
- #
362
- def self.cell_button(element_name, locator, table, column)
363
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellButton.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column});end))
364
- end
365
-
366
- # Declare and instantiate a cell checkbox in a table column on this page section.
367
- #
368
- # @param element_name [Symbol] name of cell checkbox object (as a symbol)
369
- # @param locator [String] XPath expression that uniquely identifies cell checkbox within row and column of parent table object
370
- # @param table [Symbol] Name (as a symbol) of parent table object
371
- # @param column [Integer] 1-based index of table column that contains the cell checkbox object
372
- # @example
373
- # cell_checkbox :is_registered_check, "a[@class='registered']", :data_table, 4
374
- #
375
- def self.cell_checkbox(element_name, locator, table, column, proxy = nil)
376
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellCheckBox.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column}, #{proxy});end))
377
- end
378
-
379
- # Declare and instantiate a cell radio in a table column on this page section.
380
- #
381
- # @param element_name [Symbol] name of cell radio object (as a symbol)
382
- # @param locator [String] XPath expression that uniquely identifies cell radio within row and column of parent table object
383
- # @param table [Symbol] Name (as a symbol) of parent table object
384
- # @param column [Integer] 1-based index of table column that contains the cell radio object
385
- # @example
386
- # cell_radio :track_a_radio, "a[@class='track_a']", :data_table, 8
387
- #
388
- def self.cell_radio(element_name, locator, table, column, proxy = nil)
389
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column}, #{proxy});end))
390
- end
391
-
392
- # Declare and instantiate a cell image in a table column on this page object.
393
- #
394
- # @param element_name [Symbol] name of cell image object (as a symbol)
395
- # @param locator [String] XPath expression that uniquely identifies cell image within row and column of parent table object
396
- # @param table [Symbol] Name (as a symbol) of parent table object
397
- # @param column [Integer] 1-based index of table column that contains the cell image object
398
- # @example
399
- # cell_image :ready_icon, "img[@class='ready']", :data_table, 3
400
- # cell_image :send_icon, "img[@class='send']", :data_table, 3
401
- #
402
- def self.cell_image(element_name, locator, table, column)
403
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellImage.new("#{element_name}", self, "#{locator}", :section, #{table}, #{column});end))
404
- end
405
-
406
- # Declare and instantiate a list button in a row of a list object on this section object.
407
- #
408
- # @param element_name [Symbol] name of list button object (as a symbol)
409
- # @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
410
- # @param list [Symbol] Name (as a symbol) of parent list object
411
- # @example
412
- # list_button :delete_button, "a[@class='delete']", :icon_list
413
- # list_button :edit_button, "a[@class='edit']", :icon_list
414
- #
415
- def self.list_button(element_name, locator, list)
416
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :section, #{list});end))
417
- end
418
-
419
- # Declare and instantiate a list checkbox in a row of a list object on this section object.
420
- #
421
- # @param element_name [Symbol] name of list checkbox object (as a symbol)
422
- # @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
423
- # @param list [Symbol] Name (as a symbol) of parent list object
424
- # @example
425
- # list_checkbox :is_registered_check, "a[@class='registered']", :data_list
426
- #
427
- def self.list_checkbox(element_name, locator, list, proxy = nil)
428
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :section, #{list}, #{proxy});end))
429
- end
430
-
431
- # Declare and instantiate a list radio in a row of a list object on this section object.
432
- #
433
- # @param element_name [Symbol] name of list radio object (as a symbol)
434
- # @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
435
- # @param list [Symbol] Name (as a symbol) of parent list object
436
- # @example
437
- # list_radio :sharing_radio, "a[@class='sharing']", :data_list
438
- #
439
- def self.list_radio(element_name, locator, list, proxy = nil)
440
- class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :section, #{list}, #{proxy});end))
441
- end
442
-
443
- # Instantiate a single PageSection object within this PageSection object.
444
- #
445
- # @param section_name [Symbol] name of PageSection object (as a symbol)
446
- # @param class_name [String] Class name of PageSection object
447
- # @example
448
- # section :search_form, SearchForm
449
- #
450
- def self.section(section_name, class_name, locator = nil)
451
- class_eval(%(def #{section_name};@#{section_name} ||= #{class_name}.new("#{section_name}", self, "#{locator}", :section);end))
452
- end
453
-
454
- def self.sections(section_hash)
455
- section_hash.each do |section_name, class_name|
456
- section(section_name, class_name)
457
- end
458
- end
459
-
460
- # Does Section object exists?
461
- #
462
- # @return [Boolean]
463
- # @example
464
- # navigation_toolbar.exists?
465
- #
466
- def exists?
467
- section, = find_section
468
- section != nil
469
- end
470
-
471
- # Is Section object enabled?
472
- #
473
- # @return [Boolean]
474
- # @example
475
- # bar_chart_section.enabled?
476
- #
477
- def enabled?
478
- !disabled?
479
- end
480
-
481
- # Is Section object disabled (not enabled)?
482
- #
483
- # @return [Boolean]
484
- # @example
485
- # bar_chart_section.disabled?
486
- #
487
- def disabled?
488
- obj, = find_element
489
- object_not_found_exception(obj, nil)
490
- obj.disabled?
491
- end
492
-
493
- # Is Section object visible?
494
- #
495
- # @return [Boolean]
496
- # @example
497
- # navigation_toolbar.visible?
498
- #
499
- def visible?
500
- section, = find_section
501
- exists = section
502
- visible = false
503
- visible = section.visible? if exists
504
- # the section is visible if it exists and it is not invisible
505
- exists && visible ? true : false
506
- end
507
-
508
- # Is Section object hidden (not visible)?
509
- #
510
- # @return [Boolean]
511
- # @example
512
- # navigation_toolbar.hidden?
513
- #
514
- def hidden?
515
- !visible?
516
- end
517
-
518
- # Wait until the Section object exists, or until the specified wait time has expired.
519
- #
520
- # @param seconds [Integer or Float] wait time in seconds
521
- # @example
522
- # navigation_toolbar.wait_until_exists(0.5)
523
- #
524
- def wait_until_exists(seconds = nil)
525
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
526
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
527
- wait.until { exists? }
528
- rescue
529
- raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless exists?
530
- end
531
-
532
- # Wait until the Section object no longer exists, or until the specified wait time has expired.
533
- #
534
- # @param seconds [Integer or Float] wait time in seconds
535
- # @example
536
- # navigation_toolbar.wait_until_gone(5)
537
- #
538
- def wait_until_gone(seconds = nil)
539
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
540
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
541
- wait.until { !exists? }
542
- rescue
543
- raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if exists?
544
- end
545
-
546
- # Wait until the Section object is visible, or until the specified wait time has expired.
547
- #
548
- # @param seconds [Integer or Float] wait time in seconds
549
- # @example
550
- # bar_chart_section.wait_until_visible(0.5)
551
- #
552
- def wait_until_visible(seconds = nil)
553
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
554
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
555
- wait.until { visible? }
556
- rescue
557
- raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless visible?
558
- end
559
-
560
- # Wait until the Section object is hidden, or until the specified wait time has expired.
561
- #
562
- # @param seconds [Integer or Float] wait time in seconds
563
- # @example
564
- # bar_chart_section.wait_until_hidden(10)
565
- #
566
- def wait_until_hidden(seconds = nil)
567
- timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
568
- wait = Selenium::WebDriver::Wait.new(timeout: timeout)
569
- wait.until { hidden? }
570
- rescue
571
- raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if visible?
572
- end
573
-
574
- # Click at a specific location within a Section object
575
- #
576
- # @param x [Integer] X offset
577
- # @param y [Integer] Y offset
578
- # @example
579
- # bar_chart_section.click_at(10, 10)
580
- #
581
- def click_at(x, y)
582
- section, = find_section
583
- raise "Section object '#{get_name}' (#{get_locator}) not found" unless section
584
- section.click_at(x, y)
585
- end
586
-
587
- def verify_ui_states(ui_states)
588
- ui_states.each do |ui_object, object_states|
589
- object_states.each do |property, state|
590
- case property
591
- when :class
592
- actual = ui_object.get_attribute(:class)
593
- when :exists
594
- actual = ui_object.exists?
595
- when :enabled
596
- actual = ui_object.enabled?
597
- when :disabled
598
- actual = ui_object.disabled?
599
- when :visible
600
- actual = ui_object.visible?
601
- when :hidden
602
- actual = ui_object.hidden?
603
- when :width
604
- actual = ui_object.get_width
605
- when :height
606
- actual = ui_object.get_height
607
- when :readonly
608
- actual = ui_object.read_only?
609
- when :checked
610
- actual = ui_object.checked?
611
- when :selected
612
- actual = ui_object.selected?
613
- when :value, :caption
614
- actual = ui_object.get_value
615
- when :maxlength
616
- actual = ui_object.get_max_length
617
- when :rowcount
618
- actual = ui_object.get_row_count
619
- when :columncount
620
- actual = ui_object.get_column_count
621
- when :placeholder
622
- actual = ui_object.get_placeholder
623
- when :min
624
- actual = ui_object.get_min
625
- when :max
626
- actual = ui_object.get_max
627
- when :step
628
- actual = ui_object.get_step
629
- when :options, :items, :list_items
630
- actual = ui_object.get_list_items
631
- when :optioncount, :itemcount
632
- actual = ui_object.get_item_count
633
- when :column_headers
634
- actual = ui_object.get_header_columns
635
- when :siebel_options
636
- actual = ui_object.get_siebel_options
637
- else
638
- if property.is_a?(Hash)
639
- property.each do |key, value|
640
- case key
641
- when :cell
642
- actual = ui_object.get_table_cell(value[0].to_i, value[1].to_i)
643
- when :row
644
- actual = ui_object.get_table_row(value.to_i)
645
- when :column
646
- actual = ui_object.get_table_column(value.to_i)
647
- when :item
648
- actual = ui_object.get_list_item(value.to_i)
649
- when :attribute
650
- actual = ui_object.get_attribute(value)
651
- when :native_attribute
652
- actual = ui_object.get_native_attribute(value)
653
- end
654
- end
655
- else
656
- props = property.to_s.split('_')
657
- case props[0].to_sym
658
- when :cell
659
- cell = property.to_s.delete('cell_')
660
- cell = cell.split('_')
661
- actual = ui_object.get_table_cell(cell[0].to_i, cell[1].to_i)
662
- when :row
663
- row = property.to_s.delete('row_')
664
- actual = ui_object.get_table_row(row.to_i)
665
- when :column
666
- column = property.to_s.delete('column_')
667
- actual = ui_object.get_table_column(column.to_i)
668
- when :item
669
- item = property.to_s.delete('item_')
670
- actual = ui_object.get_list_item(item.to_i)
671
- end
672
- end
673
- end
674
-
675
- if state.is_a?(Hash) && state.length == 1
676
- error_msg = "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
677
- state.each do |key, value|
678
- case key
679
- when :lt, :less_than
680
- ExceptionQueue.enqueue_exception("#{error_msg} be less than #{value} but found '#{actual}'") unless actual < value
681
- when :lt_eq, :less_than_or_equal
682
- ExceptionQueue.enqueue_exception("#{error_msg} be less than or equal to #{value} but found '#{actual}'") unless actual <= value
683
- when :gt, :greater_than
684
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than #{value} but found '#{actual}'") unless actual > value
685
- when :gt_eq, :greater_than_or_equal
686
- ExceptionQueue.enqueue_exception("#{error_msg} be greater than or equal to #{value} but found '#{actual}'") unless actual >= value
687
- when :starts_with
688
- ExceptionQueue.enqueue_exception("#{error_msg} start with '#{value}' but found '#{actual}'") unless actual.start_with?(value)
689
- when :ends_with
690
- ExceptionQueue.enqueue_exception("#{error_msg} end with '#{value}' but found '#{actual}'") unless actual.end_with?(value)
691
- when :contains
692
- ExceptionQueue.enqueue_exception("#{error_msg} contain '#{value}' but found '#{actual}'") unless actual.include?(value)
693
- when :not_contains, :does_not_contain
694
- ExceptionQueue.enqueue_exception("#{error_msg} not contain '#{value}' but found '#{actual}'") if actual.include?(value)
695
- when :not_equal
696
- ExceptionQueue.enqueue_exception("#{error_msg} not equal '#{value}' but found '#{actual}'") if actual == value
697
- when :like, :is_like
698
- actual_like = actual.delete("\n")
699
- actual_like = actual_like.delete("\r")
700
- actual_like = actual_like.delete("\t")
701
- actual_like = actual_like.delete(' ')
702
- actual_like = actual_like.downcase
703
- expected = value.delete("\n")
704
- expected = expected.delete("\r")
705
- expected = expected.delete("\t")
706
- expected = expected.delete(' ')
707
- expected = expected.downcase
708
- ExceptionQueue.enqueue_exception("#{error_msg} be like '#{value}' but found '#{actual}'") unless actual_like.include?(expected)
709
- when :translate
710
- expected = I18n.t(value)
711
- ExceptionQueue.enqueue_assert_equal(expected, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) translated #{property} property")
712
- end
713
- end
714
- else
715
- ExceptionQueue.enqueue_assert_equal(state, actual, "Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property")
716
- end
717
- end
718
- end
719
- ExceptionQueue.post_exceptions
720
- end
721
-
722
- # Populate the specified UI elements in this Section object with the associated data from a Hash passed as an
723
- # argument. Data values must be in the form of a String for textfield and select list controls. For checkbox
724
- # and radio buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1,
725
- # 0, true, false).
726
- #
727
- # To delete all text content in a text field, pass !DELETE as the data to be entered.
728
- #
729
- # @param data [Hash] UI element(s) and associated data to be entered
730
- # @example
731
- # data = { prefix_select => 'Mr.',
732
- # first_name_field => 'Ignatious',
733
- # last_name_field => 'Snickelfritz',
734
- # gender_select => 'Male',
735
- # dob_field => '12/14/1957',
736
- # organ_donor_check => 'Yes',
737
- # dnr_on_file_check => 'Yes'
738
- # }
739
- # populate_data_fields(data)
740
- #
741
- def populate_data_fields(data)
742
- data.each do |data_field, data_param|
743
- unless data_param.blank?
744
- # make sure the intended UI target element exists before trying to set its value
745
- data_field.wait_until_exists(2)
746
- if data_param == '!DELETE'
747
- length = data_field.get_value.length
748
- length.times do
749
- data_field.send_keys(:backspace)
750
- end
751
- sleep(0.5)
752
- data_field.send_keys(:tab)
753
- else
754
- case data_field.get_object_type
755
- when :checkbox
756
- data_field.set_checkbox_state(data_param.to_bool)
757
- when :selectlist
758
- data_field.get_siebel_object_type == 'JComboBox' ?
759
- data_field.set("#{data_param}\t") :
760
- data_field.choose_option(data_param)
761
- when :radio
762
- data_field.set_selected_state(data_param.to_bool)
763
- when :textfield
764
- data_field.set("#{data_param}\t")
765
- when :section
766
- data_field.set(data_param)
767
- end
768
- end
769
- end
770
- end
771
- end
772
-
773
- def get_attribute(attrib)
774
- section, = find_section
775
- raise "Section object '#{get_name}' (#{get_locator}) not found" unless section
776
- section[attrib]
777
- end
778
-
779
- def get_native_attribute(attrib)
780
- section, = find_section
781
- raise "Section object '#{get_name}' (#{get_locator}) not found" unless section
782
- section.native.attribute(attrib)
783
- end
784
-
785
- private
786
-
787
- def find_section
788
- locator = get_locator
789
- tries ||= 2
790
- attributes = [:id, :xpath, :css]
791
- type = attributes[tries]
792
- case type
793
- when :css
794
- locator = locator.delete('|')
795
- when :xpath
796
- locator = locator.delete('|')
797
- end
798
- obj = page.find(type, locator, :wait => 0.1)
799
- [obj, type]
800
- rescue
801
- retry if (tries -= 1) > 0
802
- [nil, nil]
803
- end
804
- end
805
- end