testcentricity_web 3.2.0 → 3.2.1
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +4 -4
- data/README.md +8 -4
- data/lib/testcentricity_web.rb +2 -1
- data/lib/testcentricity_web/data_objects/environment.rb +8 -8
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/web_core/page_object.rb +537 -0
- data/lib/testcentricity_web/web_core/page_objects_helper.rb +269 -801
- data/lib/testcentricity_web/web_core/{page_sections_helper.rb → page_section.rb} +1 -261
- data/lib/testcentricity_web/web_elements/cell_element.rb +6 -6
- data/lib/testcentricity_web/web_elements/checkbox.rb +33 -0
- data/lib/testcentricity_web/web_elements/list_element.rb +6 -6
- data/lib/testcentricity_web/web_elements/radio.rb +33 -0
- data/lib/testcentricity_web/web_elements/ui_elements_helper.rb +4 -4
- metadata +5 -4
@@ -1,801 +1,269 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
module TestCentricity
|
4
|
-
class
|
5
|
-
include Capybara::DSL
|
6
|
-
include Capybara::Node::Matchers
|
7
|
-
include Test::Unit::Assertions
|
8
|
-
|
9
|
-
# Define a trait for this page object.
|
10
|
-
#
|
11
|
-
# @param trait_name [Symbol] name of trait (as a symbol)
|
12
|
-
# @param block [&block] trait value
|
13
|
-
# @example
|
14
|
-
# trait(:page_name)
|
15
|
-
# trait(:page_url)
|
16
|
-
# trait(:page_locator)
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
# @
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
def
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
# Declare and instantiate a single File Field UI Element for this page object.
|
273
|
-
#
|
274
|
-
# @param element_name [Symbol] name of file field object (as a symbol)
|
275
|
-
# @param locator [String] CSS selector or XPath expression that uniquely identifies object
|
276
|
-
# @example
|
277
|
-
# filefield :attach_file, 's_SweFileName'
|
278
|
-
#
|
279
|
-
def self.filefield(element_name, locator)
|
280
|
-
define_page_element(element_name, TestCentricity::FileField, locator)
|
281
|
-
end
|
282
|
-
|
283
|
-
def self.filefields(element_hash)
|
284
|
-
element_hash.each(&method(:filefield))
|
285
|
-
end
|
286
|
-
|
287
|
-
# Declare and instantiate a cell button in a table column on this page object.
|
288
|
-
#
|
289
|
-
# @param element_name [Symbol] name of cell button object (as a symbol)
|
290
|
-
# @param locator [String] XPath expression that uniquely identifies cell button within row and column of parent table object
|
291
|
-
# @param table [Symbol] Name (as a symbol) of parent table object
|
292
|
-
# @param column [Integer] 1-based index of table column that contains the cell button object
|
293
|
-
# @example
|
294
|
-
# cell_button :show_button, "a[@class='show']", :data_table, 5
|
295
|
-
# cell_button :edit_button, "a[@class='edit']", :data_table, 5
|
296
|
-
#
|
297
|
-
def self.cell_button(element_name, locator, table, column)
|
298
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellButton.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column});end))
|
299
|
-
end
|
300
|
-
|
301
|
-
# Declare and instantiate a cell checkbox in a table column on this page object.
|
302
|
-
#
|
303
|
-
# @param element_name [Symbol] name of cell checkbox object (as a symbol)
|
304
|
-
# @param locator [String] XPath expression that uniquely identifies cell checkbox within row and column of parent table object
|
305
|
-
# @param table [Symbol] Name (as a symbol) of parent table object
|
306
|
-
# @param column [Integer] 1-based index of table column that contains the cell checkbox object
|
307
|
-
# @example
|
308
|
-
# cell_checkbox :is_registered_check, "a[@class='registered']", :data_table, 4
|
309
|
-
#
|
310
|
-
def self.cell_checkbox(element_name, locator, table, column, proxy = nil)
|
311
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellCheckBox.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column}, #{proxy});end))
|
312
|
-
end
|
313
|
-
|
314
|
-
# Declare and instantiate a cell radio in a table column on this page object.
|
315
|
-
#
|
316
|
-
# @param element_name [Symbol] name of cell radio object (as a symbol)
|
317
|
-
# @param locator [String] XPath expression that uniquely identifies cell radio within row and column of parent table object
|
318
|
-
# @param table [Symbol] Name (as a symbol) of parent table object
|
319
|
-
# @param column [Integer] 1-based index of table column that contains the cell radio object
|
320
|
-
# @example
|
321
|
-
# cell_radio :track_a_radio, "a[@class='track_a']", :data_table, 8
|
322
|
-
#
|
323
|
-
def self.cell_radio(element_name, locator, table, column, proxy = nil)
|
324
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellRadio.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column}, #{proxy});end))
|
325
|
-
end
|
326
|
-
|
327
|
-
# Declare and instantiate a cell image in a table column on this page object.
|
328
|
-
#
|
329
|
-
# @param element_name [Symbol] name of cell image object (as a symbol)
|
330
|
-
# @param locator [String] XPath expression that uniquely identifies cell image within row and column of parent table object
|
331
|
-
# @param table [Symbol] Name (as a symbol) of parent table object
|
332
|
-
# @param column [Integer] 1-based index of table column that contains the cell image object
|
333
|
-
# @example
|
334
|
-
# cell_image :ready_icon, "img[@class='ready']", :data_table, 3
|
335
|
-
# cell_image :send_icon, "img[@class='send']", :data_table, 3
|
336
|
-
#
|
337
|
-
def self.cell_image(element_name, locator, table, column)
|
338
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::CellImage.new("#{element_name}", self, "#{locator}", :page, #{table}, #{column});end))
|
339
|
-
end
|
340
|
-
|
341
|
-
# Declare and instantiate a list button in a row of a list object on this page object.
|
342
|
-
#
|
343
|
-
# @param element_name [Symbol] name of list button object (as a symbol)
|
344
|
-
# @param locator [String] XPath expression that uniquely identifies list button within row of parent list object
|
345
|
-
# @param list [Symbol] Name (as a symbol) of parent list object
|
346
|
-
# @example
|
347
|
-
# list_button :delete_button, "a[@class='delete']", :icon_list
|
348
|
-
# list_button :edit_button, "a[@class='edit']", :icon_list
|
349
|
-
#
|
350
|
-
def self.list_button(element_name, locator, list)
|
351
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListButton.new("#{element_name}", self, "#{locator}", :page, #{list});end))
|
352
|
-
end
|
353
|
-
|
354
|
-
# Declare and instantiate a list checkbox in a row of a list object on this page object.
|
355
|
-
#
|
356
|
-
# @param element_name [Symbol] name of list checkbox object (as a symbol)
|
357
|
-
# @param locator [String] XPath expression that uniquely identifies list checkbox within row of parent list object
|
358
|
-
# @param list [Symbol] Name (as a symbol) of parent list object
|
359
|
-
# @example
|
360
|
-
# list_checkbox :is_registered_check, "a[@class='registered']", :data_list
|
361
|
-
#
|
362
|
-
def self.list_checkbox(element_name, locator, list, proxy = nil)
|
363
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListCheckBox.new("#{element_name}", self, "#{locator}", :page, #{list}, #{proxy});end))
|
364
|
-
end
|
365
|
-
|
366
|
-
# Declare and instantiate a list radio in a row of a list object on this page object.
|
367
|
-
#
|
368
|
-
# @param element_name [Symbol] name of list radio object (as a symbol)
|
369
|
-
# @param locator [String] XPath expression that uniquely identifies list radio within row of parent list object
|
370
|
-
# @param list [Symbol] Name (as a symbol) of parent list object
|
371
|
-
# @example
|
372
|
-
# list_radio :sharing_radio, "a[@class='sharing']", :data_list
|
373
|
-
#
|
374
|
-
def self.list_radio(element_name, locator, list, proxy = nil)
|
375
|
-
class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::ListRadio.new("#{element_name}", self, "#{locator}", :page, #{list}, #{proxy});end))
|
376
|
-
end
|
377
|
-
|
378
|
-
# Instantiate a single PageSection object for this page object.
|
379
|
-
#
|
380
|
-
# @param section_name [Symbol] name of PageSection object (as a symbol)
|
381
|
-
# @param class_name [String] Class name of PageSection object
|
382
|
-
# @example
|
383
|
-
# section :search_form, SearchForm
|
384
|
-
#
|
385
|
-
def self.section(section_name, obj, locator = nil)
|
386
|
-
define_method(section_name) do
|
387
|
-
ivar_name = "@#{section_name}"
|
388
|
-
ivar = instance_variable_get(ivar_name)
|
389
|
-
return ivar if ivar
|
390
|
-
instance_variable_set(ivar_name, obj.new(section_name, self, "#{locator}", :page))
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
def self.sections(section_hash)
|
395
|
-
section_hash.each do |section_name, class_name|
|
396
|
-
section(section_name, class_name)
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
def open_portal
|
401
|
-
environment = Environ.current
|
402
|
-
url = environment.hostname.blank? ? "#{environment.base_url}#{environment.append}" : "#{environment.hostname}/#{environment.base_url}#{environment.append}"
|
403
|
-
if environment.user_id.blank? || environment.password.blank?
|
404
|
-
visit "#{environment.protocol}://#{url}"
|
405
|
-
else
|
406
|
-
visit "#{environment.protocol}://#{environment.user_id}:#{environment.password}@#{url}"
|
407
|
-
end
|
408
|
-
Environ.portal_state = :open
|
409
|
-
end
|
410
|
-
|
411
|
-
def verify_page_exists
|
412
|
-
raise "Page object #{self.class.name} does not have a page_locator trait defined" unless defined?(page_locator)
|
413
|
-
unless page.has_selector?(page_locator)
|
414
|
-
body_class = find(:xpath, '//body')[:class]
|
415
|
-
error_message = %(
|
416
|
-
Expected page to have selector '#{page_locator}' but found '#{body_class}' instead.
|
417
|
-
Actual URL of page loaded = #{URI.parse(current_url)}.
|
418
|
-
)
|
419
|
-
error_message = "#{error_message}\nExpected URL of page was #{page_url}." if defined?(page_url)
|
420
|
-
raise error_message
|
421
|
-
end
|
422
|
-
PageManager.current_page = self
|
423
|
-
end
|
424
|
-
|
425
|
-
def navigate_to; end
|
426
|
-
|
427
|
-
def verify_page_ui; end
|
428
|
-
|
429
|
-
def load_page
|
430
|
-
return if exists?
|
431
|
-
if defined?(page_url) && !page_url.nil?
|
432
|
-
visit page_url
|
433
|
-
begin
|
434
|
-
page.driver.browser.switch_to.alert.accept
|
435
|
-
rescue => e
|
436
|
-
end unless Environ.browser == :safari || Environ.browser == :ie || Environ.is_device?
|
437
|
-
else
|
438
|
-
navigate_to
|
439
|
-
end
|
440
|
-
verify_page_exists
|
441
|
-
end
|
442
|
-
|
443
|
-
def verify_page_contains(content)
|
444
|
-
raise "Expected page to have content '#{content}'" unless page.has_content?(:visible, content)
|
445
|
-
end
|
446
|
-
|
447
|
-
# Does Page object exists?
|
448
|
-
#
|
449
|
-
# @return [Boolean]
|
450
|
-
# @example
|
451
|
-
# home_page.exists?
|
452
|
-
#
|
453
|
-
def exists?
|
454
|
-
raise "Page object #{self.class.name} does not have a page_locator trait defined" unless defined?(page_locator)
|
455
|
-
saved_wait_time = Capybara.default_max_wait_time
|
456
|
-
Capybara.default_max_wait_time = 0.1
|
457
|
-
tries ||= 2
|
458
|
-
attributes = [:id, :css, :xpath]
|
459
|
-
type = attributes[tries]
|
460
|
-
obj = page.find(type, page_locator)
|
461
|
-
obj != nil
|
462
|
-
rescue
|
463
|
-
Capybara.default_max_wait_time = saved_wait_time
|
464
|
-
retry if (tries -= 1) > 0
|
465
|
-
false
|
466
|
-
ensure
|
467
|
-
Capybara.default_max_wait_time = saved_wait_time
|
468
|
-
end
|
469
|
-
|
470
|
-
# Return page title
|
471
|
-
#
|
472
|
-
# @return [String]
|
473
|
-
# @example
|
474
|
-
# home_page.title
|
475
|
-
#
|
476
|
-
def title
|
477
|
-
page.driver.browser.title
|
478
|
-
end
|
479
|
-
|
480
|
-
# Wait until the page object exists, or until the specified wait time has expired. If the wait time is nil, then the wait
|
481
|
-
# time will be Capybara.default_max_wait_time.
|
482
|
-
#
|
483
|
-
# @param seconds [Integer or Float] wait time in seconds
|
484
|
-
# @example
|
485
|
-
# home_page.wait_until_exists(15)
|
486
|
-
#
|
487
|
-
def wait_until_exists(seconds = nil, post_exception = true)
|
488
|
-
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
489
|
-
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
490
|
-
wait.until { exists? }
|
491
|
-
rescue
|
492
|
-
if post_exception
|
493
|
-
raise "Page object #{self.class.name} not found after #{timeout} seconds" unless exists?
|
494
|
-
else
|
495
|
-
exists?
|
496
|
-
end
|
497
|
-
end
|
498
|
-
|
499
|
-
# Wait until the page object no longer exists, or until the specified wait time has expired. If the wait time is nil, then
|
500
|
-
# the wait time will be Capybara.default_max_wait_time.
|
501
|
-
#
|
502
|
-
# @param seconds [Integer or Float] wait time in seconds
|
503
|
-
# @example
|
504
|
-
# payment_processing_page.wait_until_gone(15)
|
505
|
-
#
|
506
|
-
def wait_until_gone(seconds = nil, post_exception = true)
|
507
|
-
timeout = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
508
|
-
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
509
|
-
wait.until { !exists? }
|
510
|
-
rescue
|
511
|
-
if post_exception
|
512
|
-
raise "Page object #{self.class.name} remained visible after #{timeout} seconds" if exists?
|
513
|
-
else
|
514
|
-
exists?
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
# Wait until all AJAX requests have completed, or until the specified wait time has expired. If the wait time is nil, then
|
519
|
-
# the wait time will be Capybara.default_max_wait_time.
|
520
|
-
#
|
521
|
-
# @param seconds [Integer or Float] wait time in seconds
|
522
|
-
# @example
|
523
|
-
# shopping_basket_page.wait_for_ajax(15)
|
524
|
-
#
|
525
|
-
def wait_for_ajax(seconds = nil)
|
526
|
-
wait_time = seconds.nil? ? Capybara.default_max_wait_time : seconds
|
527
|
-
Timeout.timeout(wait_time) do
|
528
|
-
loop do
|
529
|
-
active = page.evaluate_script('jQuery.active')
|
530
|
-
break if active.zero?
|
531
|
-
end
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
# Is current Page object URL secure?
|
536
|
-
#
|
537
|
-
# @return [Boolean]
|
538
|
-
# @example
|
539
|
-
# home_page.secure?
|
540
|
-
#
|
541
|
-
def secure?
|
542
|
-
current_url.start_with?('https')
|
543
|
-
end
|
544
|
-
|
545
|
-
def verify_ui_states(ui_states, fail_message = nil)
|
546
|
-
ui_states.each do |ui_object, object_states|
|
547
|
-
object_states.each do |property, state|
|
548
|
-
case property
|
549
|
-
when :class
|
550
|
-
actual = ui_object.get_attribute(:class)
|
551
|
-
when :name
|
552
|
-
actual = ui_object.get_attribute(:name)
|
553
|
-
when :title
|
554
|
-
actual = ui_object.title
|
555
|
-
when :exists
|
556
|
-
actual = ui_object.exists?
|
557
|
-
when :enabled
|
558
|
-
actual = ui_object.enabled?
|
559
|
-
when :disabled
|
560
|
-
actual = ui_object.disabled?
|
561
|
-
when :visible
|
562
|
-
actual = ui_object.visible?
|
563
|
-
when :hidden
|
564
|
-
actual = ui_object.hidden?
|
565
|
-
when :displayed
|
566
|
-
actual = ui_object.displayed?
|
567
|
-
when :width
|
568
|
-
actual = ui_object.width
|
569
|
-
when :height
|
570
|
-
actual = ui_object.height
|
571
|
-
when :x
|
572
|
-
actual = ui_object.x
|
573
|
-
when :y
|
574
|
-
actual = ui_object.y
|
575
|
-
when :readonly
|
576
|
-
actual = ui_object.read_only?
|
577
|
-
when :checked
|
578
|
-
actual = ui_object.checked?
|
579
|
-
when :selected
|
580
|
-
actual = ui_object.selected?
|
581
|
-
when :value, :caption
|
582
|
-
actual = ui_object.get_value
|
583
|
-
when :maxlength
|
584
|
-
actual = ui_object.get_max_length
|
585
|
-
when :rowcount
|
586
|
-
actual = ui_object.get_row_count
|
587
|
-
when :columncount
|
588
|
-
actual = ui_object.get_column_count
|
589
|
-
when :placeholder
|
590
|
-
actual = ui_object.get_placeholder
|
591
|
-
when :min
|
592
|
-
actual = ui_object.get_min
|
593
|
-
when :max
|
594
|
-
actual = ui_object.get_max
|
595
|
-
when :step
|
596
|
-
actual = ui_object.get_step
|
597
|
-
when :loaded
|
598
|
-
actual = ui_object.loaded?
|
599
|
-
when :broken
|
600
|
-
actual = ui_object.broken?
|
601
|
-
when :alt
|
602
|
-
actual = ui_object.alt
|
603
|
-
when :src
|
604
|
-
actual = ui_object.src
|
605
|
-
when :autoplay
|
606
|
-
actual = ui_object.autoplay?
|
607
|
-
when :ended
|
608
|
-
actual = ui_object.ended?
|
609
|
-
when :controls
|
610
|
-
actual = ui_object.controls?
|
611
|
-
when :loop
|
612
|
-
actual = ui_object.loop?
|
613
|
-
when :muted
|
614
|
-
actual = ui_object.muted?
|
615
|
-
when :default_muted
|
616
|
-
actual = ui_object.default_muted?
|
617
|
-
when :paused
|
618
|
-
actual = ui_object.paused?
|
619
|
-
when :seeking
|
620
|
-
actual = ui_object.seeking?
|
621
|
-
when :current_time
|
622
|
-
actual = ui_object.current_time
|
623
|
-
when :default_playback_rate
|
624
|
-
actual = ui_object.default_playback_rate
|
625
|
-
when :duration
|
626
|
-
actual = ui_object.duration
|
627
|
-
when :playback_rate
|
628
|
-
actual = ui_object.playback_rate
|
629
|
-
when :ready_state
|
630
|
-
actual = ui_object.ready_state
|
631
|
-
when :volume
|
632
|
-
actual = ui_object.volume
|
633
|
-
when :options, :items, :list_items
|
634
|
-
actual = ui_object.get_list_items
|
635
|
-
when :optioncount, :itemcount
|
636
|
-
actual = ui_object.get_item_count
|
637
|
-
when :groupcount
|
638
|
-
actual = ui_object.get_group_count
|
639
|
-
when :group_headings
|
640
|
-
actual = ui_object.get_group_headings
|
641
|
-
when :all_items, :all_list_items
|
642
|
-
actual = ui_object.get_all_list_items
|
643
|
-
when :all_items_count
|
644
|
-
actual = ui_object.get_all_items_count
|
645
|
-
when :column_headers
|
646
|
-
actual = ui_object.get_header_columns
|
647
|
-
when :count, :count_visible
|
648
|
-
actual = ui_object.count(visible = true)
|
649
|
-
when :count_all
|
650
|
-
actual = ui_object.count(visible = :all)
|
651
|
-
when :siebel_options
|
652
|
-
actual = ui_object.get_siebel_options
|
653
|
-
when :style
|
654
|
-
actual = ui_object.style
|
655
|
-
when :href
|
656
|
-
actual = ui_object.href
|
657
|
-
when :role
|
658
|
-
actual = ui_object.role
|
659
|
-
when :aria_label
|
660
|
-
actual = ui_object.aria_label
|
661
|
-
when :aria_disabled
|
662
|
-
actual = ui_object.aria_disabled?
|
663
|
-
when :tabindex
|
664
|
-
actual = ui_object.tabindex
|
665
|
-
when :aria_labelledby
|
666
|
-
actual = ui_object.aria_labelledby
|
667
|
-
when :aria_describedby
|
668
|
-
actual = ui_object.aria_describedby
|
669
|
-
when :aria_live
|
670
|
-
actual = ui_object.aria_live
|
671
|
-
when :aria_selected
|
672
|
-
actual = ui_object.aria_selected?
|
673
|
-
when :aria_hidden
|
674
|
-
actual = ui_object.aria_hidden?
|
675
|
-
when :aria_expanded
|
676
|
-
actual = ui_object.aria_expanded?
|
677
|
-
when :aria_required
|
678
|
-
actual = ui_object.aria_required?
|
679
|
-
when :aria_invalid
|
680
|
-
actual = ui_object.aria_invalid?
|
681
|
-
when :aria_checked
|
682
|
-
actual = ui_object.aria_checked?
|
683
|
-
when :aria_readonly
|
684
|
-
actual = ui_object.aria_readonly?
|
685
|
-
when :aria_pressed
|
686
|
-
actual = ui_object.aria_pressed?
|
687
|
-
when :aria_haspopup
|
688
|
-
actual = ui_object.aria_haspopup?
|
689
|
-
when :aria_sort
|
690
|
-
actual = ui_object.aria_sort
|
691
|
-
when :aria_rowcount
|
692
|
-
actual = ui_object.aria_rowcount
|
693
|
-
when :aria_colcount
|
694
|
-
actual = ui_object.aria_colcount
|
695
|
-
else
|
696
|
-
if property.is_a?(Hash)
|
697
|
-
property.each do |key, value|
|
698
|
-
case key
|
699
|
-
when :cell
|
700
|
-
actual = ui_object.get_table_cell(value[0].to_i, value[1].to_i)
|
701
|
-
when :row
|
702
|
-
actual = ui_object.get_table_row(value.to_i)
|
703
|
-
when :column
|
704
|
-
actual = ui_object.get_table_column(value.to_i)
|
705
|
-
when :item
|
706
|
-
actual = ui_object.get_list_item(value.to_i)
|
707
|
-
when :attribute
|
708
|
-
actual = ui_object.get_attribute(value)
|
709
|
-
when :native_attribute
|
710
|
-
actual = ui_object.get_native_attribute(value)
|
711
|
-
end
|
712
|
-
end
|
713
|
-
end
|
714
|
-
end
|
715
|
-
error_msg = if ui_object.respond_to?(:get_name)
|
716
|
-
"Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
|
717
|
-
else
|
718
|
-
"Expected '#{page_name}' page object #{property} property to"
|
719
|
-
end
|
720
|
-
ExceptionQueue.enqueue_comparison(ui_object, state, actual, error_msg)
|
721
|
-
end
|
722
|
-
end
|
723
|
-
rescue ObjectNotFoundError => e
|
724
|
-
ExceptionQueue.enqueue_exception(e.message)
|
725
|
-
ensure
|
726
|
-
ExceptionQueue.post_exceptions(fail_message)
|
727
|
-
end
|
728
|
-
|
729
|
-
# Populate the specified UI elements on this page with the associated data from a Hash passed as an argument. Data
|
730
|
-
# values must be in the form of a String for textfield and select list controls. For checkbox and radio buttons,
|
731
|
-
# data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1, 0, true, false).
|
732
|
-
#
|
733
|
-
# The optional wait_time parameter is used to specify the time (in seconds) to wait for each UI element to become
|
734
|
-
# visible before entering the associated data value. This option is useful in situations where entering data, or
|
735
|
-
# setting the state of a UI element might cause other UI elements to become visible or active. Specifying a wait_time
|
736
|
-
# value ensures that the subsequent UI elements will be ready to be interacted with as states are changed. If the wait
|
737
|
-
# time is nil, then the wait time will be 5 seconds.
|
738
|
-
#
|
739
|
-
# To delete all text content in a text field, pass !DELETE as the data to be entered.
|
740
|
-
#
|
741
|
-
# @param data [Hash] UI element(s) and associated data to be entered
|
742
|
-
# @param wait_time [Integer] wait time in seconds
|
743
|
-
# @param integrity_check [Boolean] if TRUE, ensure that text entered into text fields matches what was entered
|
744
|
-
# @example
|
745
|
-
# field_data = { prefix_select => 'Ms',
|
746
|
-
# first_name_field => 'Priscilla',
|
747
|
-
# last_name_field => 'Pumperknickle',
|
748
|
-
# gender_select => 'Female',
|
749
|
-
# dob_field => '11/18/1976',
|
750
|
-
# email_field => 'p.pumperknickle4876@gmail.com',
|
751
|
-
# mailing_list_check => 'Yes'
|
752
|
-
# }
|
753
|
-
# populate_data_fields(field_data)
|
754
|
-
#
|
755
|
-
def populate_data_fields(data, wait_time = nil, integrity_check = false)
|
756
|
-
timeout = wait_time.nil? ? 5 : wait_time
|
757
|
-
data.each do |data_field, data_param|
|
758
|
-
unless data_param.blank?
|
759
|
-
# make sure the intended UI target element is visible before trying to set its value
|
760
|
-
data_field.wait_until_visible(timeout)
|
761
|
-
if data_param == '!DELETE'
|
762
|
-
data_field.clear
|
763
|
-
else
|
764
|
-
case data_field.get_object_type
|
765
|
-
when :checkbox
|
766
|
-
data_field.set_checkbox_state(data_param.to_bool)
|
767
|
-
when :selectlist
|
768
|
-
if data_field.get_siebel_object_type == 'JComboBox'
|
769
|
-
data_field.set("#{data_param}\t")
|
770
|
-
else
|
771
|
-
data_field.choose_option(data_param)
|
772
|
-
end
|
773
|
-
when :radio
|
774
|
-
data_field.set_selected_state(data_param.to_bool)
|
775
|
-
when :textfield
|
776
|
-
data_field.set("#{data_param}\t")
|
777
|
-
if integrity_check && data_field.get_value != data_param
|
778
|
-
data_field.set('')
|
779
|
-
data_field.send_keys(data_param)
|
780
|
-
data_field.send_keys(:tab)
|
781
|
-
end
|
782
|
-
when :section
|
783
|
-
data_field.set(data_param)
|
784
|
-
end
|
785
|
-
end
|
786
|
-
end
|
787
|
-
end
|
788
|
-
end
|
789
|
-
|
790
|
-
private
|
791
|
-
|
792
|
-
def self.define_page_element(element_name, obj, locator)
|
793
|
-
define_method(element_name) do
|
794
|
-
ivar_name = "@#{element_name}"
|
795
|
-
ivar = instance_variable_get(ivar_name)
|
796
|
-
return ivar if ivar
|
797
|
-
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :page))
|
798
|
-
end
|
799
|
-
end
|
800
|
-
end
|
801
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
module TestCentricity
|
4
|
+
class BasePageSectionObject
|
5
|
+
include Capybara::DSL
|
6
|
+
include Capybara::Node::Matchers
|
7
|
+
include Test::Unit::Assertions
|
8
|
+
|
9
|
+
# Define a trait for this page or section object.
|
10
|
+
#
|
11
|
+
# @param trait_name [Symbol] name of trait (as a symbol)
|
12
|
+
# @param block [&block] trait value
|
13
|
+
# @example
|
14
|
+
# trait(:page_name) { 'Shopping Basket' }
|
15
|
+
# trait(:page_url) { '/shopping_basket' }
|
16
|
+
# trait(:page_locator) { "//body[@class='shopping_baskets']" }
|
17
|
+
# trait(:section_locator) { "//div[@class='Messaging_Applet']" }
|
18
|
+
# trait(:list_table_name) { '#Messages' }
|
19
|
+
#
|
20
|
+
def self.trait(trait_name, &block)
|
21
|
+
define_method(trait_name.to_s, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def verify_ui_states(ui_states, fail_message = nil)
|
25
|
+
ui_states.each do |ui_object, object_states|
|
26
|
+
object_states.each do |property, state|
|
27
|
+
actual = case property
|
28
|
+
when :class
|
29
|
+
ui_object.get_attribute(:class)
|
30
|
+
when :name
|
31
|
+
ui_object.get_attribute(:name)
|
32
|
+
when :title
|
33
|
+
ui_object.title
|
34
|
+
when :exists
|
35
|
+
ui_object.exists?
|
36
|
+
when :enabled
|
37
|
+
ui_object.enabled?
|
38
|
+
when :disabled
|
39
|
+
ui_object.disabled?
|
40
|
+
when :visible
|
41
|
+
ui_object.visible?
|
42
|
+
when :hidden
|
43
|
+
ui_object.hidden?
|
44
|
+
when :displayed
|
45
|
+
ui_object.displayed?
|
46
|
+
when :width
|
47
|
+
ui_object.width
|
48
|
+
when :height
|
49
|
+
ui_object.height
|
50
|
+
when :x
|
51
|
+
ui_object.x
|
52
|
+
when :y
|
53
|
+
ui_object.y
|
54
|
+
when :readonly
|
55
|
+
ui_object.read_only?
|
56
|
+
when :checked
|
57
|
+
ui_object.checked?
|
58
|
+
when :selected
|
59
|
+
ui_object.selected?
|
60
|
+
when :value, :caption
|
61
|
+
ui_object.get_value
|
62
|
+
when :maxlength
|
63
|
+
ui_object.get_max_length
|
64
|
+
when :rowcount
|
65
|
+
ui_object.get_row_count
|
66
|
+
when :columncount
|
67
|
+
ui_object.get_column_count
|
68
|
+
when :placeholder
|
69
|
+
ui_object.get_placeholder
|
70
|
+
when :min
|
71
|
+
ui_object.get_min
|
72
|
+
when :max
|
73
|
+
ui_object.get_max
|
74
|
+
when :step
|
75
|
+
ui_object.get_step
|
76
|
+
when :loaded
|
77
|
+
ui_object.loaded?
|
78
|
+
when :broken
|
79
|
+
ui_object.broken?
|
80
|
+
when :alt
|
81
|
+
ui_object.alt
|
82
|
+
when :src
|
83
|
+
ui_object.src
|
84
|
+
when :autoplay
|
85
|
+
ui_object.autoplay?
|
86
|
+
when :ended
|
87
|
+
ui_object.ended?
|
88
|
+
when :controls
|
89
|
+
ui_object.controls?
|
90
|
+
when :loop
|
91
|
+
ui_object.loop?
|
92
|
+
when :muted
|
93
|
+
ui_object.muted?
|
94
|
+
when :default_muted
|
95
|
+
ui_object.default_muted?
|
96
|
+
when :paused
|
97
|
+
ui_object.paused?
|
98
|
+
when :seeking
|
99
|
+
ui_object.seeking?
|
100
|
+
when :current_time
|
101
|
+
ui_object.current_time
|
102
|
+
when :default_playback_rate
|
103
|
+
ui_object.default_playback_rate
|
104
|
+
when :duration
|
105
|
+
ui_object.duration
|
106
|
+
when :playback_rate
|
107
|
+
ui_object.playback_rate
|
108
|
+
when :ready_state
|
109
|
+
ui_object.ready_state
|
110
|
+
when :volume
|
111
|
+
ui_object.volume
|
112
|
+
when :options, :items, :list_items
|
113
|
+
ui_object.get_list_items
|
114
|
+
when :optioncount, :itemcount
|
115
|
+
ui_object.get_item_count
|
116
|
+
when :groupcount
|
117
|
+
ui_object.get_group_count
|
118
|
+
when :group_headings
|
119
|
+
ui_object.get_group_headings
|
120
|
+
when :all_items, :all_list_items
|
121
|
+
ui_object.get_all_list_items
|
122
|
+
when :all_items_count
|
123
|
+
ui_object.get_all_items_count
|
124
|
+
when :column_headers
|
125
|
+
ui_object.get_header_columns
|
126
|
+
when :count, :count_visible
|
127
|
+
ui_object.count(visible = true)
|
128
|
+
when :count_all
|
129
|
+
ui_object.count(visible = :all)
|
130
|
+
when :siebel_options
|
131
|
+
ui_object.get_siebel_options
|
132
|
+
when :style
|
133
|
+
ui_object.style
|
134
|
+
when :href
|
135
|
+
ui_object.href
|
136
|
+
when :role
|
137
|
+
ui_object.role
|
138
|
+
when :aria_label
|
139
|
+
ui_object.aria_label
|
140
|
+
when :aria_disabled
|
141
|
+
ui_object.aria_disabled?
|
142
|
+
when :tabindex
|
143
|
+
ui_object.tabindex
|
144
|
+
when :aria_labelledby
|
145
|
+
ui_object.aria_labelledby
|
146
|
+
when :aria_describedby
|
147
|
+
ui_object.aria_describedby
|
148
|
+
when :aria_live
|
149
|
+
ui_object.aria_live
|
150
|
+
when :aria_selected
|
151
|
+
ui_object.aria_selected?
|
152
|
+
when :aria_hidden
|
153
|
+
ui_object.aria_hidden?
|
154
|
+
when :aria_expanded
|
155
|
+
ui_object.aria_expanded?
|
156
|
+
when :aria_required
|
157
|
+
ui_object.aria_required?
|
158
|
+
when :aria_invalid
|
159
|
+
ui_object.aria_invalid?
|
160
|
+
when :aria_checked
|
161
|
+
ui_object.aria_checked?
|
162
|
+
when :aria_readonly
|
163
|
+
ui_object.aria_readonly?
|
164
|
+
when :aria_pressed
|
165
|
+
ui_object.aria_pressed?
|
166
|
+
when :aria_haspopup
|
167
|
+
ui_object.aria_haspopup?
|
168
|
+
when :aria_sort
|
169
|
+
ui_object.aria_sort
|
170
|
+
when :aria_rowcount
|
171
|
+
ui_object.aria_rowcount
|
172
|
+
when :aria_colcount
|
173
|
+
ui_object.aria_colcount
|
174
|
+
else
|
175
|
+
if property.is_a?(Hash)
|
176
|
+
property.each do |key, value|
|
177
|
+
case key
|
178
|
+
when :cell
|
179
|
+
ui_object.get_table_cell(value[0].to_i, value[1].to_i)
|
180
|
+
when :row
|
181
|
+
ui_object.get_table_row(value.to_i)
|
182
|
+
when :column
|
183
|
+
ui_object.get_table_column(value.to_i)
|
184
|
+
when :item
|
185
|
+
ui_object.get_list_item(value.to_i)
|
186
|
+
when :attribute
|
187
|
+
ui_object.get_attribute(value)
|
188
|
+
when :native_attribute
|
189
|
+
ui_object.get_native_attribute(value)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
error_msg = if ui_object.respond_to?(:get_name)
|
195
|
+
"Expected UI object '#{ui_object.get_name}' (#{ui_object.get_locator}) #{property} property to"
|
196
|
+
else
|
197
|
+
"Expected '#{page_name}' page object #{property} property to"
|
198
|
+
end
|
199
|
+
ExceptionQueue.enqueue_comparison(ui_object, state, actual, error_msg)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
rescue ObjectNotFoundError => e
|
203
|
+
ExceptionQueue.enqueue_exception(e.message)
|
204
|
+
ensure
|
205
|
+
ExceptionQueue.post_exceptions(fail_message)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Populate the specified UI elements on this page or section object with the associated data from a Hash passed as an
|
209
|
+
# argument. Data values must be in the form of a String for textfield and selectlist controls. For checkbox and radio
|
210
|
+
# buttons, data must either be a Boolean or a String that evaluates to a Boolean value (Yes, No, 1, 0, true, false).
|
211
|
+
#
|
212
|
+
# The optional wait_time parameter is used to specify the time (in seconds) to wait for each UI element to become
|
213
|
+
# visible before entering the associated data value. This option is useful in situations where entering data, or
|
214
|
+
# setting the state of a UI element might cause other UI elements to become visible or active. Specifying a wait_time
|
215
|
+
# value ensures that the subsequent UI elements will be ready to be interacted with as states are changed. If the wait
|
216
|
+
# time is nil, then the wait time will be 5 seconds.
|
217
|
+
#
|
218
|
+
# To delete all text content in a text field, pass !DELETE as the data to be entered.
|
219
|
+
#
|
220
|
+
# @param data [Hash] UI element(s) and associated data to be entered
|
221
|
+
# @param wait_time [Integer] wait time in seconds
|
222
|
+
# @param integrity_check [Boolean] if TRUE, ensure that text entered into text fields matches what was entered
|
223
|
+
# @example
|
224
|
+
# field_data = { prefix_select => 'Ms',
|
225
|
+
# first_name_field => 'Priscilla',
|
226
|
+
# last_name_field => 'Pumperknickle',
|
227
|
+
# gender_select => 'Female',
|
228
|
+
# dob_field => '11/18/1976',
|
229
|
+
# email_field => 'p.pumperknickle4876@gmail.com',
|
230
|
+
# mailing_list_check => 'Yes'
|
231
|
+
# }
|
232
|
+
# populate_data_fields(field_data)
|
233
|
+
#
|
234
|
+
def populate_data_fields(data, wait_time = nil, integrity_check = false)
|
235
|
+
timeout = wait_time.nil? ? 5 : wait_time
|
236
|
+
data.each do |data_field, data_param|
|
237
|
+
unless data_param.blank?
|
238
|
+
# make sure the intended UI target element is visible before trying to set its value
|
239
|
+
data_field.wait_until_visible(timeout)
|
240
|
+
if data_param == '!DELETE'
|
241
|
+
data_field.clear
|
242
|
+
else
|
243
|
+
case data_field.get_object_type
|
244
|
+
when :checkbox
|
245
|
+
data_field.set_checkbox_state(data_param.to_bool)
|
246
|
+
when :selectlist
|
247
|
+
if data_field.get_siebel_object_type == 'JComboBox'
|
248
|
+
data_field.set("#{data_param}\t")
|
249
|
+
else
|
250
|
+
data_field.choose_option(data_param)
|
251
|
+
end
|
252
|
+
when :radio
|
253
|
+
data_field.set_selected_state(data_param.to_bool)
|
254
|
+
when :textfield
|
255
|
+
data_field.set("#{data_param}\t")
|
256
|
+
if integrity_check && data_field.get_value != data_param
|
257
|
+
data_field.set('')
|
258
|
+
data_field.send_keys(data_param)
|
259
|
+
data_field.send_keys(:tab)
|
260
|
+
end
|
261
|
+
when :section
|
262
|
+
data_field.set(data_param)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|