testcentricity_web 4.3.0 → 4.4.0

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -11
  3. data/LICENSE.md +1 -1
  4. data/README.md +1931 -801
  5. data/lib/devices/devices.yml +144 -216
  6. data/lib/testcentricity_web/browser_helper.rb +33 -4
  7. data/lib/testcentricity_web/data_objects/environment.rb +96 -15
  8. data/lib/testcentricity_web/exception_queue_helper.rb +5 -6
  9. data/lib/testcentricity_web/version.rb +1 -1
  10. data/lib/testcentricity_web/web_core/page_object.rb +53 -49
  11. data/lib/testcentricity_web/web_core/page_objects_helper.rb +20 -11
  12. data/lib/testcentricity_web/web_core/page_section.rb +31 -34
  13. data/lib/testcentricity_web/web_core/webdriver_helper.rb +416 -288
  14. data/lib/testcentricity_web/web_elements/audio.rb +6 -4
  15. data/lib/testcentricity_web/web_elements/button.rb +7 -4
  16. data/lib/testcentricity_web/web_elements/checkbox.rb +149 -147
  17. data/lib/testcentricity_web/web_elements/file_field.rb +38 -36
  18. data/lib/testcentricity_web/web_elements/image.rb +75 -70
  19. data/lib/testcentricity_web/web_elements/label.rb +6 -4
  20. data/lib/testcentricity_web/web_elements/link.rb +15 -13
  21. data/lib/testcentricity_web/web_elements/list.rb +171 -169
  22. data/lib/testcentricity_web/web_elements/media.rb +384 -379
  23. data/lib/testcentricity_web/web_elements/radio.rb +135 -133
  24. data/lib/testcentricity_web/web_elements/range.rb +16 -29
  25. data/lib/testcentricity_web/web_elements/select_list.rb +247 -245
  26. data/lib/testcentricity_web/web_elements/table.rb +575 -573
  27. data/lib/testcentricity_web/web_elements/textfield.rb +143 -139
  28. data/lib/testcentricity_web/web_elements/ui_element.rb +1171 -0
  29. data/lib/testcentricity_web/web_elements/video.rb +39 -37
  30. data/lib/testcentricity_web/world_extensions.rb +37 -4
  31. data/lib/testcentricity_web.rb +4 -23
  32. metadata +27 -79
  33. data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +0 -1148
@@ -84,8 +84,10 @@ module TestCentricity
84
84
  attr_accessor :device_os
85
85
  attr_accessor :device_os_version
86
86
  attr_accessor :device_orientation
87
+ attr_accessor :screen_size
87
88
  attr_accessor :platform
88
89
  attr_accessor :driver
90
+ attr_accessor :driver_name
89
91
  attr_accessor :grid
90
92
  attr_accessor :tunneling
91
93
  attr_accessor :locale
@@ -98,7 +100,6 @@ module TestCentricity
98
100
  attr_accessor :portal_status
99
101
  attr_accessor :portal_context
100
102
  attr_accessor :external_page
101
-
102
103
  attr_accessor :a11y_standard
103
104
 
104
105
  attr_accessor :protocol
@@ -116,6 +117,13 @@ module TestCentricity
116
117
  attr_accessor :dns
117
118
  attr_accessor :db_username
118
119
  attr_accessor :db_password
120
+ attr_accessor :ios_app_path
121
+ attr_accessor :ios_ipa_path
122
+ attr_accessor :android_apk_path
123
+ attr_accessor :default_max_wait_time
124
+ attr_accessor :deep_link_prefix
125
+ attr_accessor :ios_bundle_id
126
+ attr_accessor :android_app_id
119
127
 
120
128
  def initialize(data)
121
129
  @protocol = data['PROTOCOL']
@@ -133,6 +141,12 @@ module TestCentricity
133
141
  @dns = data['DNS']
134
142
  @db_username = data['DB_USERNAME']
135
143
  @db_password = data['DB_PASSWORD']
144
+ @ios_app_path = data['IOS_APP_PATH']
145
+ @ios_ipa_path = data['IOS_IPA_PATH']
146
+ @android_apk_path = data['ANDROID_APK_PATH']
147
+ @deep_link_prefix = data['DEEP_LINK_PREFIX']
148
+ @ios_bundle_id = data['IOS_BUNDLE_ID']
149
+ @android_app_id = data['ANDROID_APP_ID']
136
150
 
137
151
  url = @hostname.blank? ? "#{@base_url}#{@append}" : "#{@hostname}/#{@base_url}#{@append}"
138
152
  @app_host = if @user_id.blank? || @password.blank?
@@ -144,6 +158,45 @@ module TestCentricity
144
158
  super
145
159
  end
146
160
 
161
+ def self.driver_state
162
+ {
163
+ driver_name: @driver_name,
164
+ driver: @driver,
165
+ app_host: @app_host,
166
+ browser: @browser,
167
+ browser_size: @browser_size,
168
+ headless: @headless,
169
+ os: @os,
170
+ device: @device,
171
+ device_name: @device_name,
172
+ device_type: @device_type,
173
+ device_os: @device_os,
174
+ device_os_version: @device_os_version,
175
+ device_orientation: @device_orientation,
176
+ platform: @platform,
177
+ grid: @grid,
178
+ tunneling: @tunneling
179
+ }
180
+ end
181
+
182
+ def self.restore_driver_state(driver_state)
183
+ @driver = driver_state[:driver]
184
+ @app_host = driver_state[:app_host]
185
+ @browser = driver_state[:browser]
186
+ @browser_size = driver_state[:browser_size]
187
+ @headless = driver_state[:headless]
188
+ @os = driver_state[:os]
189
+ @device = driver_state[:device]
190
+ @device_name = driver_state[:device_name]
191
+ @device_type = driver_state[:device_type]
192
+ @device_os = driver_state[:device_os]
193
+ @device_os_version = driver_state[:device_os_version]
194
+ @device_orientation = driver_state[:device_orientation]
195
+ @platform = driver_state[:platform]
196
+ @grid = driver_state[:grid]
197
+ @tunneling = driver_state[:tunneling]
198
+ end
199
+
147
200
  def self.app_host
148
201
  @app_host
149
202
  end
@@ -188,6 +241,16 @@ module TestCentricity
188
241
  end
189
242
  end
190
243
 
244
+ def self.default_max_wait_time=(timeout)
245
+ @default_max_wait_time = timeout
246
+
247
+ Capybara.default_max_wait_time = timeout if driver == :webdriver
248
+ end
249
+
250
+ def self.default_max_wait_time
251
+ @default_max_wait_time
252
+ end
253
+
191
254
  def self.browser=(browser)
192
255
  @browser = browser.downcase.to_sym
193
256
  end
@@ -249,7 +312,8 @@ module TestCentricity
249
312
  end
250
313
 
251
314
  def self.device_type=(type)
252
- @device_type = type.downcase.to_sym
315
+ type = type.downcase.to_sym if type.is_a?(String)
316
+ @device_type = type
253
317
  end
254
318
 
255
319
  def self.device_type
@@ -265,7 +329,8 @@ module TestCentricity
265
329
  end
266
330
 
267
331
  def self.device_os=(os)
268
- @device_os = os.downcase.to_sym
332
+ os = os.downcase.to_sym if os.is_a?(String)
333
+ @device_os = os
269
334
  end
270
335
 
271
336
  def self.device_os
@@ -289,13 +354,22 @@ module TestCentricity
289
354
  end
290
355
 
291
356
  def self.device_orientation=(orientation)
292
- @device_orientation = orientation.downcase.to_sym
357
+ orientation = orientation.downcase.to_sym if orientation.is_a?(String)
358
+ @device_orientation = orientation
293
359
  end
294
360
 
295
361
  def self.device_orientation
296
362
  @device_orientation
297
363
  end
298
364
 
365
+ def self.screen_size=(size)
366
+ @screen_size = size
367
+ end
368
+
369
+ def self.screen_size
370
+ @screen_size
371
+ end
372
+
299
373
  def self.driver=(type)
300
374
  @driver = type
301
375
  end
@@ -304,6 +378,15 @@ module TestCentricity
304
378
  @driver
305
379
  end
306
380
 
381
+ def self.driver_name=(name)
382
+ name = name.downcase.to_sym if name.is_a?(String)
383
+ @driver_name = name
384
+ end
385
+
386
+ def self.driver_name
387
+ @driver_name
388
+ end
389
+
307
390
  def self.grid=(type)
308
391
  @grid = type
309
392
  end
@@ -396,22 +479,20 @@ module TestCentricity
396
479
  @screen_shots = []
397
480
  end
398
481
 
399
- # :nocov:
400
482
  def self.report_header
401
483
  report_header = "\n<b><u>TEST ENVIRONMENT</u>:</b> #{ENV['TEST_ENVIRONMENT']}\n"\
402
- " <b>Browser:</b>\t #{Environ.browser.capitalize}\n"
403
- report_header = "#{report_header} <b>Device:</b>\t #{Environ.device_name}\n" if Environ.device_name
404
- report_header = "#{report_header} <b>Device OS:</b>\t #{Environ.device_os} #{Environ.device_os_version}\n" if Environ.device_os
405
- report_header = "#{report_header} <b>Device type:</b>\t #{Environ.device_type}\n" if Environ.device_type
406
- report_header = "#{report_header} <b>Driver:</b>\t #{Environ.driver}\n" if Environ.driver
407
- report_header = "#{report_header} <b>Grid:</b>\t\t #{Environ.grid}\n" if Environ.grid
408
- report_header = "#{report_header} <b>OS:</b>\t\t #{Environ.os}\n" if Environ.os
409
- report_header = "#{report_header} <b>Locale:</b>\t #{Environ.locale}\n" if Environ.locale
410
- report_header = "#{report_header} <b>Language:</b>\t #{Environ.language}\n" if Environ.language
484
+ " <b>Browser:</b>\t #{@browser.capitalize}\n"
485
+ report_header = "#{report_header} <b>Device:</b>\t #{@device_name}\n" if @device_name
486
+ report_header = "#{report_header} <b>Device OS:</b>\t #{@device_os} #{@device_os_version}\n" if @device_os
487
+ report_header = "#{report_header} <b>Device type:</b>\t #{@device_type}\n" if @device_type
488
+ report_header = "#{report_header} <b>Driver:</b>\t #{@driver}\n" if @driver
489
+ report_header = "#{report_header} <b>Grid:</b>\t\t #{@grid}\n" if @grid
490
+ report_header = "#{report_header} <b>OS:</b>\t\t #{@os}\n" if @os
491
+ report_header = "#{report_header} <b>Locale:</b>\t #{@locale}\n" if @locale
492
+ report_header = "#{report_header} <b>Language:</b>\t #{@language}\n" if @language
411
493
  report_header = "#{report_header} <b>Country:</b>\t #{ENV['COUNTRY']}\n" if ENV['COUNTRY']
412
494
  report_header = "#{report_header} <b>WCAG Accessibility Standard:</b>\t #{ENV['ACCESSIBILITY_STANDARD']}\n" if ENV['ACCESSIBILITY_STANDARD']
413
495
  "#{report_header}\n\n"
414
496
  end
415
- # :nocov:
416
497
  end
417
498
  end
@@ -102,6 +102,8 @@ module TestCentricity
102
102
  "#{expected.split.each{ |expected| expected.capitalize! }.join(' ')}"
103
103
  end
104
104
  enqueue_assert_equal(expected, actual, error_msg)
105
+ else
106
+ raise "#{key} is not a valid comparison key"
105
107
  end
106
108
  end
107
109
  else
@@ -119,17 +121,14 @@ module TestCentricity
119
121
  timestamp = Time.now.strftime('%Y%m%d%H%M%S%L')
120
122
  filename = "Screenshot-#{timestamp}.png"
121
123
  path = File.join Dir.pwd, 'reports/screenshots/', filename
122
- # highlight the active UI element prior to taking a screenshot
124
+ # scroll into view and highlight the active UI element prior to taking a screenshot
123
125
  unless @active_ui_element.nil? || @mru_ui_element == @active_ui_element
126
+ @active_ui_element.scroll_to(:bottom)
124
127
  @active_ui_element.highlight(0)
125
128
  @mru_ui_element = @active_ui_element
126
129
  end
127
130
  # take screenshot
128
- if Environ.driver == :appium
129
- AppiumConnect.take_screenshot(path)
130
- else
131
- Capybara.save_screenshot path
132
- end
131
+ Capybara.save_screenshot path
133
132
  # unhighlight the active UI element
134
133
  @mru_ui_element.unhighlight unless @mru_ui_element.blank?
135
134
  # add screenshot to queue
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '4.3.0'
2
+ VERSION = '4.4.0'
3
3
  end
@@ -12,19 +12,19 @@ module TestCentricity
12
12
  # element :settings_item, 'a#userPreferencesTrigger'
13
13
  #
14
14
  def self.element(element_name, locator)
15
- define_page_element(element_name, TestCentricity::UIElement, locator)
15
+ define_page_element(element_name, TestCentricity::Elements::UIElement, locator)
16
16
  end
17
17
 
18
18
  # Declare and instantiate a collection of generic UI Elements for this page object.
19
19
  #
20
20
  # @param element_hash [Hash] names of UI objects (as a symbol) and CSS selectors or XPath expressions that uniquely identifies objects
21
21
  # @example
22
- # elements profile_item: 'a#profile',
23
- # settings_item: 'a#userPreferencesTrigger',
24
- # log_out_item: 'a#logout'
22
+ # elements profile_item: 'a#profile',
23
+ # settings_item: 'a#userPreferencesTrigger',
24
+ # log_out_item: 'a#logout'
25
25
  #
26
26
  def self.elements(element_hash)
27
- element_hash.each(&method(:element))
27
+ element_hash.each_pair { |element_name, locator| element(element_name, locator) }
28
28
  end
29
29
 
30
30
  # Declare and instantiate a single button UI Element for this page object.
@@ -36,7 +36,7 @@ module TestCentricity
36
36
  # button :login_button, "//input[@id='submit_button']"
37
37
  #
38
38
  def self.button(element_name, locator)
39
- define_page_element(element_name, TestCentricity::Button, locator)
39
+ define_page_element(element_name, TestCentricity::Elements::Button, locator)
40
40
  end
41
41
 
42
42
  # Declare and instantiate a collection of buttons for this page object.
@@ -48,7 +48,7 @@ module TestCentricity
48
48
  # cancel_button: 'button#cancel'
49
49
  #
50
50
  def self.buttons(element_hash)
51
- element_hash.each(&method(:button))
51
+ element_hash.each_pair { |element_name, locator| button(element_name, locator) }
52
52
  end
53
53
 
54
54
  # Declare and instantiate a single text field UI Element for this page object.
@@ -60,21 +60,20 @@ module TestCentricity
60
60
  # textfield :password_field, 'input#consumer_password'
61
61
  #
62
62
  def self.textfield(element_name, locator)
63
- define_page_element(element_name, TestCentricity::TextField, locator)
63
+ define_page_element(element_name, TestCentricity::Elements::TextField, locator)
64
64
  end
65
65
 
66
66
  # Declare and instantiate a collection of text fields for this page object.
67
67
  #
68
68
  # @param element_hash [Hash] names of text fields (as a symbol) and CSS selectors or XPath expressions that uniquely identifies text fields
69
69
  # @example
70
- # textfields name_field: 'input#Name',
71
- # title_field: 'input#Title',
72
- # phone_field: 'input#PhoneNumber',
73
- # fax_field: 'input#FaxNumber',
74
- # email_field: 'input#Email'
70
+ # textfields name_field: 'input#Name',
71
+ # title_field: 'input#Title',
72
+ # phone_field: 'input#PhoneNumber',
73
+ # email_field: 'input#Email'
75
74
  #
76
75
  def self.textfields(element_hash)
77
- element_hash.each(&method(:textfield))
76
+ element_hash.each_pair { |element_name, locator| textfield(element_name, locator) }
78
77
  end
79
78
 
80
79
  # Declare and instantiate a single range input UI Element for this page object.
@@ -86,7 +85,7 @@ module TestCentricity
86
85
  # range :points_slider, 'input#points'
87
86
  #
88
87
  def self.range(element_name, locator)
89
- define_page_element(element_name, TestCentricity::Range, locator)
88
+ define_page_element(element_name, TestCentricity::Elements::Range, locator)
90
89
  end
91
90
 
92
91
  # Declare and instantiate a collection of range inputs for this page object.
@@ -97,7 +96,7 @@ module TestCentricity
97
96
  # risk_slider: 'input#risk_percentage'
98
97
  #
99
98
  def self.ranges(element_hash)
100
- element_hash.each(&method(:range))
99
+ element_hash.each_pair { |element_name, locator| range(element_name, locator) }
101
100
  end
102
101
 
103
102
  # Declare and instantiate a single checkbox UI Element for this page object.
@@ -109,20 +108,20 @@ module TestCentricity
109
108
  # checkbox :accept_terms_checkbox, 'input#accept_terms_conditions'
110
109
  #
111
110
  def self.checkbox(element_name, locator)
112
- define_page_element(element_name, TestCentricity::CheckBox, locator)
111
+ define_page_element(element_name, TestCentricity::Elements::CheckBox, locator)
113
112
  end
114
113
 
115
114
  # Declare and instantiate a collection of checkboxes for this page object.
116
115
  #
117
116
  # @param element_hash [Hash] names of checkboxes (as a symbol) and CSS selectors or XPath expressions that uniquely identifies checkboxes
118
117
  # @example
119
- # checkboxes hazmat_certified_check: 'input#hazmatCertified',
120
- # epa_certified_check: 'input#epaCertified',
121
- # dhs_certified_check: 'input#homelandSecurityCertified',
122
- # carb_compliant_check: 'input#carbCompliant'
118
+ # checkboxes hazmat_certified_check: 'input#hazmatCertified',
119
+ # epa_certified_check: 'input#epaCertified',
120
+ # dhs_certified_check: 'input#homelandSecurityCertified',
121
+ # carb_compliant_check: 'input#carbCompliant'
123
122
  #
124
123
  def self.checkboxes(element_hash)
125
- element_hash.each(&method(:checkbox))
124
+ element_hash.each_pair { |element_name, locator| checkbox(element_name, locator) }
126
125
  end
127
126
 
128
127
  # Declare and instantiate a single radio button UI Element for this page object.
@@ -134,20 +133,20 @@ module TestCentricity
134
133
  # radio :decline_terms_radio, '#decline_terms_conditions'
135
134
  #
136
135
  def self.radio(element_name, locator)
137
- define_page_element(element_name, TestCentricity::Radio, locator)
136
+ define_page_element(element_name, TestCentricity::Elements::Radio, locator)
138
137
  end
139
138
 
140
139
  # Declare and instantiate a collection of radio buttons for this page object.
141
140
  #
142
141
  # @param element_hash [Hash] names of radio buttons (as a symbol) and CSS selectors or XPath expressions that uniquely identifies radio buttons
143
142
  # @example
144
- # radios visa_radio: 'input#payWithVisa',
145
- # mastercard_radio: 'input#payWithMastercard',
146
- # discover_radio: 'input#payWithDiscover',
147
- # amex_radio: 'input#payWithAmEx'
143
+ # radios visa_radio: 'input#payWithVisa',
144
+ # mastercard_radio: 'input#payWithMastercard',
145
+ # discover_radio: 'input#payWithDiscover',
146
+ # amex_radio: 'input#payWithAmEx'
148
147
  #
149
148
  def self.radios(element_hash)
150
- element_hash.each(&method(:radio))
149
+ element_hash.each_pair { |element_name, locator| radio(element_name, locator) }
151
150
  end
152
151
 
153
152
  # Declare and instantiate a single label UI Element for this page object.
@@ -159,11 +158,18 @@ module TestCentricity
159
158
  # label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
160
159
  #
161
160
  def self.label(element_name, locator)
162
- define_page_element(element_name, TestCentricity::Label, locator)
161
+ define_page_element(element_name, TestCentricity::Elements::Label, locator)
163
162
  end
164
163
 
164
+ # Declare and instantiate a collection of labels for this page object.
165
+ #
166
+ # @param element_hash [Hash] names of labels (as a symbol) and CSS selectors or XPath expressions that uniquely identifies labels
167
+ # @example
168
+ # labels username_label: 'label#username',
169
+ # password_label: 'label#password'
170
+ #
165
171
  def self.labels(element_hash)
166
- element_hash.each(&method(:label))
172
+ element_hash.each_pair { |element_name, locator| label(element_name, locator) }
167
173
  end
168
174
 
169
175
  # Declare and instantiate a single link UI Element for this page object.
@@ -175,11 +181,11 @@ module TestCentricity
175
181
  # link :shopping_basket_link, "//a[@href='shopping_basket']"
176
182
  #
177
183
  def self.link(element_name, locator)
178
- define_page_element(element_name, TestCentricity::Link, locator)
184
+ define_page_element(element_name, TestCentricity::Elements::Link, locator)
179
185
  end
180
186
 
181
187
  def self.links(element_hash)
182
- element_hash.each(&method(:link))
188
+ element_hash.each_pair { |element_name, locator| link(element_name, locator) }
183
189
  end
184
190
 
185
191
  # Declare and instantiate a single table UI Element for this page object.
@@ -190,11 +196,11 @@ module TestCentricity
190
196
  # table :payments_table, "//table[@class='payments_table']"
191
197
  #
192
198
  def self.table(element_name, locator)
193
- define_page_element(element_name, TestCentricity::Table, locator)
199
+ define_page_element(element_name, TestCentricity::Elements::Table, locator)
194
200
  end
195
201
 
196
202
  def self.tables(element_hash)
197
- element_hash.each(&method(:table))
203
+ element_hash.each_pair { |element_name, locator| table(element_name, locator) }
198
204
  end
199
205
 
200
206
  # Declare and instantiate a single select list UI Element for this page object.
@@ -206,11 +212,11 @@ module TestCentricity
206
212
  # selectlist :gender_select, "//select[@id='customer_gender']"
207
213
  #
208
214
  def self.selectlist(element_name, locator)
209
- define_page_element(element_name, TestCentricity::SelectList, locator)
215
+ define_page_element(element_name, TestCentricity::Elements::SelectList, locator)
210
216
  end
211
217
 
212
218
  def self.selectlists(element_hash)
213
- element_hash.each(&method(:selectlist))
219
+ element_hash.each_pair { |element_name, locator| selectlist(element_name, locator) }
214
220
  end
215
221
 
216
222
  # Declare and instantiate a single list UI Element for this page object.
@@ -221,11 +227,11 @@ module TestCentricity
221
227
  # list :x_axis_list, 'g.x-axis'
222
228
  #
223
229
  def self.list(element_name, locator)
224
- define_page_element(element_name, TestCentricity::List, locator)
230
+ define_page_element(element_name, TestCentricity::Elements::List, locator)
225
231
  end
226
232
 
227
233
  def self.lists(element_hash)
228
- element_hash.each(&method(:list))
234
+ element_hash.each_pair { |element_name, locator| list(element_name, locator) }
229
235
  end
230
236
 
231
237
  # Declare and instantiate an single image UI Element for this page object.
@@ -237,11 +243,11 @@ module TestCentricity
237
243
  # image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
238
244
  #
239
245
  def self.image(element_name, locator)
240
- define_page_element(element_name, TestCentricity::Image, locator)
246
+ define_page_element(element_name, TestCentricity::Elements::Image, locator)
241
247
  end
242
248
 
243
249
  def self.images(element_hash)
244
- element_hash.each(&method(:image))
250
+ element_hash.each_pair { |element_name, locator| image(element_name, locator) }
245
251
  end
246
252
 
247
253
  # Declare and instantiate a single HTML5 video UI Element for this page object.
@@ -252,11 +258,11 @@ module TestCentricity
252
258
  # video :video_player, 'video#my_video_player'
253
259
  #
254
260
  def self.video(element_name, locator)
255
- define_page_element(element_name, TestCentricity::Video, locator)
261
+ define_page_element(element_name, TestCentricity::Elements::Video, locator)
256
262
  end
257
263
 
258
264
  def self.videos(element_hash)
259
- element_hash.each(&method(:video))
265
+ element_hash.each_pair { |element_name, locator| video(element_name, locator) }
260
266
  end
261
267
 
262
268
  # Declare and instantiate a single HTML5 audio UI Element for this page object.
@@ -267,11 +273,11 @@ module TestCentricity
267
273
  # audio :audio_player, 'audio#my_audio_player'
268
274
  #
269
275
  def self.audio(element_name, locator)
270
- define_page_element(element_name, TestCentricity::Audio, locator)
276
+ define_page_element(element_name, TestCentricity::Elements::Audio, locator)
271
277
  end
272
278
 
273
279
  def self.audios(element_hash)
274
- element_hash.each(&method(:audio))
280
+ element_hash.each_pair { |element_name, locator| audio(element_name, locator) }
275
281
  end
276
282
 
277
283
  # Declare and instantiate a single File Field UI Element for this page object.
@@ -282,11 +288,11 @@ module TestCentricity
282
288
  # filefield :attach_file, 's_SweFileName'
283
289
  #
284
290
  def self.filefield(element_name, locator)
285
- define_page_element(element_name, TestCentricity::FileField, locator)
291
+ define_page_element(element_name, TestCentricity::Elements::FileField, locator)
286
292
  end
287
293
 
288
294
  def self.filefields(element_hash)
289
- element_hash.each(&method(:filefield))
295
+ element_hash.each_pair { |element_name, locator| filefield(element_name, locator) }
290
296
  end
291
297
 
292
298
  # Instantiate a single PageSection object for this page object.
@@ -306,9 +312,7 @@ module TestCentricity
306
312
  end
307
313
 
308
314
  def self.sections(section_hash)
309
- section_hash.each do |section_name, class_name|
310
- section(section_name, class_name)
311
- end
315
+ section_hash.each_pair { |section_name, class_name| section(section_name, class_name) }
312
316
  end
313
317
 
314
318
  def open_portal
@@ -163,26 +163,27 @@ module TestCentricity
163
163
  ui_object.get_group_count
164
164
  when :group_headings
165
165
  ui_object.get_group_headings
166
- when :all_items, :all_list_items
167
- ui_object.get_all_list_items
168
- when :all_items_count
169
- ui_object.get_all_items_count
170
166
  when :column_headers
171
167
  ui_object.get_header_columns
172
168
  when :count, :count_visible
173
169
  ui_object.count(visible = true)
174
- when :count_all
175
- ui_object.count(visible = :all)
170
+ when :all_items, :all_list_items
171
+ ui_object.get_all_list_items
172
+ when :all_items_count
173
+ ui_object.get_all_items_count
176
174
  when :style
177
175
  ui_object.style
178
176
  when :href
179
177
  ui_object.href
180
178
  when :role
181
179
  ui_object.role
182
- when :aria_label
183
- ui_object.aria_label
184
180
  when :aria_disabled
185
181
  ui_object.aria_disabled?
182
+ # :nocov:
183
+ when :count_all
184
+ ui_object.count(visible = :all)
185
+ when :aria_label
186
+ ui_object.aria_label
186
187
  when :tabindex
187
188
  ui_object.tabindex
188
189
  when :aria_labelledby
@@ -243,6 +244,7 @@ module TestCentricity
243
244
  ui_object.aria_multiselectable?
244
245
  when :content_editable
245
246
  ui_object.content_editable?
247
+ # :nocov:
246
248
  when :validation_message
247
249
  ui_object.validation_message
248
250
  when :badInput
@@ -283,8 +285,12 @@ module TestCentricity
283
285
  ui_object.get_attribute(value)
284
286
  when :native_attribute
285
287
  ui_object.get_native_attribute(value)
288
+ else
289
+ raise "#{key} is not a valid property key"
286
290
  end
287
291
  end
292
+ else
293
+ raise "#{property} is not a valid property"
288
294
  end
289
295
  end
290
296
  error_msg = if ui_object.respond_to?(:get_name)
@@ -295,8 +301,8 @@ module TestCentricity
295
301
  ExceptionQueue.enqueue_comparison(ui_object, state, actual, error_msg)
296
302
  end
297
303
  end
298
- rescue ObjectNotFoundError => e
299
- ExceptionQueue.enqueue_exception(e.message)
304
+ rescue ObjectNotFoundError => error
305
+ ExceptionQueue.enqueue_exception(error.message)
300
306
  ensure
301
307
  error_msg = "#{fail_message}\nPage URL = #{URI.parse(current_url)}"
302
308
  ExceptionQueue.post_exceptions(error_msg)
@@ -388,8 +394,11 @@ module TestCentricity
388
394
  page.driver.browser.action.send_keys(key).perform
389
395
  sleep(0.5)
390
396
  focused_obj = page.driver.browser.switch_to.active_element
397
+ expected_element.reset_mru_cache
391
398
  expected_obj, = expected_element.find_element(visible = :all)
392
- raise "Expected element '#{expected_element.get_name}' to have focus but found '#{focused_obj[:id]} is focused instead'" unless focused_obj == expected_obj.native
399
+ unless focused_obj == expected_obj.native
400
+ raise "Expected element '#{expected_element.get_name}' to have focus but found '#{focused_obj[:id]} is focused instead'"
401
+ end
393
402
 
394
403
  puts "Element '#{expected_element.get_name}' is focused as expected"
395
404
  end