testcentricity_web 2.1.10 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +138 -116
- data/lib/devices/devices.yml +86 -44
- data/lib/testcentricity_web/browser_helper.rb +1 -0
- data/lib/testcentricity_web/elements/cell_element.rb +9 -2
- data/lib/testcentricity_web/elements/checkbox.rb +1 -0
- data/lib/testcentricity_web/elements/list.rb +8 -1
- data/lib/testcentricity_web/elements/list_element.rb +12 -2
- data/lib/testcentricity_web/elements/radio.rb +1 -0
- data/lib/testcentricity_web/elements/select_list.rb +2 -0
- data/lib/testcentricity_web/elements/table.rb +198 -59
- data/lib/testcentricity_web/environment.rb +19 -1
- data/lib/testcentricity_web/page_sections_helper.rb +26 -14
- data/lib/testcentricity_web/ui_elements_helper.rb +59 -60
- data/lib/testcentricity_web/version.rb +1 -1
- data/lib/testcentricity_web/webdriver_helper.rb +172 -81
- data/testcentricity_web.gemspec +2 -2
- metadata +5 -5
@@ -12,12 +12,19 @@ module TestCentricity
|
|
12
12
|
@table = table
|
13
13
|
@column = column
|
14
14
|
@element_locator = locator
|
15
|
-
|
15
|
+
|
16
|
+
set_locator_type(@table.get_locator)
|
17
|
+
set_column(column)
|
16
18
|
end
|
17
19
|
|
18
20
|
def set_column(column)
|
19
21
|
@column = column
|
20
|
-
|
22
|
+
case @locator_type
|
23
|
+
when :xpath
|
24
|
+
@locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)}/#{@element_locator}"
|
25
|
+
when :css
|
26
|
+
@locator = "#{@table.get_table_cell_locator('ROW_SPEC', @column)} > #{@element_locator}"
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
30
|
def exists?(row)
|
@@ -13,6 +13,8 @@ module TestCentricity
|
|
13
13
|
case element
|
14
14
|
when :list_item
|
15
15
|
@list_item = value
|
16
|
+
else
|
17
|
+
raise "#{element} is not a recognized list element"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -43,7 +45,12 @@ module TestCentricity
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def get_list_row_locator(row)
|
46
|
-
|
48
|
+
case @locator_type
|
49
|
+
when :xpath
|
50
|
+
"#{@locator}/#{@list_item}[#{row}]"
|
51
|
+
when :css
|
52
|
+
"#{@locator} > #{@list_item}:nth-of-type(#{row})"
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
@@ -10,9 +10,19 @@ module TestCentricity
|
|
10
10
|
@alt_locator = nil
|
11
11
|
@list = list
|
12
12
|
@element_locator = locator
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
set_locator_type
|
15
|
+
|
16
|
+
if locator.nil?
|
17
|
+
@locator = list.get_list_row_locator('ROW_SPEC')
|
18
|
+
else
|
19
|
+
case @locator_type
|
20
|
+
when :xpath
|
15
21
|
@locator = "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
|
22
|
+
when :css
|
23
|
+
@locator = "#{list.get_list_row_locator('ROW_SPEC')} > #{@element_locator}"
|
24
|
+
end
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
def exists?(row)
|
@@ -20,9 +20,16 @@ module TestCentricity
|
|
20
20
|
:table_column => 'td',
|
21
21
|
:table_header => 'thead',
|
22
22
|
:header_row => 'tr',
|
23
|
-
:header_column => 'th'
|
24
|
-
|
25
|
-
|
23
|
+
:header_column => 'th' }
|
24
|
+
|
25
|
+
case @locator_type
|
26
|
+
when :xpath
|
27
|
+
table_spec[:tree_expand] = "div/div[contains(@class, 'tree-plus treeclick')]"
|
28
|
+
table_spec[:tree_collapse] = "div/div[contains(@class, 'tree-minus treeclick')]"
|
29
|
+
when :css
|
30
|
+
table_spec[:tree_expand] = "div/div[class*='tree-plus treeclick']"
|
31
|
+
table_spec[:tree_collapse] = "div/div[class*='tree-minus treeclick']"
|
32
|
+
end
|
26
33
|
define_table_elements(table_spec)
|
27
34
|
end
|
28
35
|
|
@@ -47,6 +54,8 @@ module TestCentricity
|
|
47
54
|
@tree_expand = value
|
48
55
|
when :tree_collapse
|
49
56
|
@tree_collapse = value
|
57
|
+
else
|
58
|
+
raise "#{element} is not a recognized table element"
|
50
59
|
end
|
51
60
|
end
|
52
61
|
end
|
@@ -59,10 +68,19 @@ module TestCentricity
|
|
59
68
|
#
|
60
69
|
def get_row_count
|
61
70
|
wait_until_exists(5)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
case @locator_type
|
72
|
+
when :xpath
|
73
|
+
if @table_section.nil?
|
74
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}", :visible => :all).count
|
75
|
+
else
|
76
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}", :visible => :all).count
|
77
|
+
end
|
78
|
+
when :css
|
79
|
+
if @table_section.nil?
|
80
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_row}", :visible => :all).count
|
81
|
+
else
|
82
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_section}", :visible => :all).count
|
83
|
+
end
|
66
84
|
end
|
67
85
|
end
|
68
86
|
|
@@ -74,17 +92,34 @@ module TestCentricity
|
|
74
92
|
#
|
75
93
|
def get_column_count
|
76
94
|
row_count = get_row_count
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
95
|
+
case @locator_type
|
96
|
+
when :xpath
|
97
|
+
if row_count == 0
|
98
|
+
page.all(:xpath, "#{@locator}/#{@table_header}/#{@header_row}/#{@header_column}", :visible => :all).count
|
99
|
+
else
|
100
|
+
if @table_section.nil?
|
101
|
+
row_count == 1 ?
|
102
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}/#{@table_column}", :visible => :all).count :
|
103
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_row}[2]/#{@table_column}", :visible => :all).count
|
104
|
+
else
|
105
|
+
row_count == 1 ?
|
106
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}/#{@table_row}/#{@table_column}", :visible => :all).count :
|
107
|
+
page.all(:xpath, "#{@locator}/#{@table_body}/#{@table_section}[2]/#{@table_row}/#{@table_column}", :visible => :all).count
|
108
|
+
end
|
109
|
+
end
|
110
|
+
when :css
|
111
|
+
if row_count == 0
|
112
|
+
page.all(:css, "#{@locator} > #{@table_header} > #{@header_row} > #{@header_column}", :visible => :all).count
|
84
113
|
else
|
85
|
-
|
86
|
-
|
87
|
-
|
114
|
+
if @table_section.nil?
|
115
|
+
row_count == 1 ?
|
116
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_row} > #{@table_column}", :visible => :all).count :
|
117
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(2) > #{@table_column}", :visible => :all).count
|
118
|
+
else
|
119
|
+
row_count == 1 ?
|
120
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_section} > #{@table_row} > #{@table_column}", :visible => :all).count :
|
121
|
+
page.all(:css, "#{@locator} > #{@table_body} > #{@table_section}:nth-of-type(2) > #{@table_row} > #{@table_column}", :visible => :all).count
|
122
|
+
end
|
88
123
|
end
|
89
124
|
end
|
90
125
|
end
|
@@ -154,16 +189,31 @@ module TestCentricity
|
|
154
189
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
155
190
|
set_table_cell_locator(row, column)
|
156
191
|
saved_locator = @alt_locator
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
unless exists?
|
161
|
-
set_alt_locator("#{saved_locator}//input")
|
162
|
-
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
163
|
-
send_keys(:tab) if exists?
|
164
|
-
set_alt_locator("#{saved_locator}//a")
|
192
|
+
case @locator_type
|
193
|
+
when :xpath
|
194
|
+
set_alt_locator("#{@alt_locator}//a")
|
165
195
|
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
166
|
-
|
196
|
+
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
197
|
+
unless exists?
|
198
|
+
set_alt_locator("#{saved_locator}//input")
|
199
|
+
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
200
|
+
send_keys(:tab) if exists?
|
201
|
+
set_alt_locator("#{saved_locator}//a")
|
202
|
+
set_alt_locator("#{saved_locator}//span/a") unless exists?
|
203
|
+
send_keys(:tab) unless exists?
|
204
|
+
end
|
205
|
+
when :css
|
206
|
+
set_alt_locator("#{@alt_locator} a")
|
207
|
+
set_alt_locator("#{saved_locator} span > a") unless exists?
|
208
|
+
# if link not present, check for text entry fields and try to dismiss by tabbing out
|
209
|
+
unless exists?
|
210
|
+
set_alt_locator("#{saved_locator} input")
|
211
|
+
set_alt_locator("#{saved_locator} textarea") unless exists?
|
212
|
+
send_keys(:tab) if exists?
|
213
|
+
set_alt_locator("#{saved_locator} a")
|
214
|
+
set_alt_locator("#{saved_locator} span > a") unless exists?
|
215
|
+
send_keys(:tab) unless exists?
|
216
|
+
end
|
167
217
|
end
|
168
218
|
wait_until_exists(1)
|
169
219
|
click
|
@@ -179,10 +229,19 @@ module TestCentricity
|
|
179
229
|
value = ''
|
180
230
|
set_table_cell_locator(row, column)
|
181
231
|
saved_locator = @alt_locator
|
182
|
-
|
183
|
-
|
184
|
-
set_alt_locator("#{saved_locator}//
|
185
|
-
|
232
|
+
case @locator_type
|
233
|
+
when :xpath
|
234
|
+
set_alt_locator("#{saved_locator}//input")
|
235
|
+
unless exists?
|
236
|
+
set_alt_locator("#{saved_locator}//textarea")
|
237
|
+
set_alt_locator(saved_locator) unless exists?
|
238
|
+
end
|
239
|
+
when :css
|
240
|
+
set_alt_locator("#{saved_locator} input")
|
241
|
+
unless exists?
|
242
|
+
set_alt_locator("#{saved_locator} textarea")
|
243
|
+
set_alt_locator(saved_locator) unless exists?
|
244
|
+
end
|
186
245
|
end
|
187
246
|
value = get_value if exists?
|
188
247
|
columns.push(value)
|
@@ -194,9 +253,16 @@ module TestCentricity
|
|
194
253
|
def get_row_data(row)
|
195
254
|
row_count = get_row_count
|
196
255
|
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
197
|
-
|
198
|
-
|
199
|
-
|
256
|
+
case @locator_type
|
257
|
+
when :xpath
|
258
|
+
row > 1 ?
|
259
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
|
260
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
|
261
|
+
when :css
|
262
|
+
row > 1 ?
|
263
|
+
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
|
264
|
+
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
|
265
|
+
end
|
200
266
|
value = get_value if exists?
|
201
267
|
clear_alt_locator
|
202
268
|
value
|
@@ -211,10 +277,19 @@ module TestCentricity
|
|
211
277
|
value = ''
|
212
278
|
set_table_cell_locator(row, column)
|
213
279
|
saved_locator = @alt_locator
|
214
|
-
|
215
|
-
|
216
|
-
set_alt_locator("#{saved_locator}//
|
217
|
-
|
280
|
+
case @locator_type
|
281
|
+
when :xpath
|
282
|
+
set_alt_locator("#{saved_locator}//input")
|
283
|
+
unless exists?
|
284
|
+
set_alt_locator("#{saved_locator}//textarea")
|
285
|
+
set_alt_locator(saved_locator) unless exists?
|
286
|
+
end
|
287
|
+
when :css
|
288
|
+
set_alt_locator("#{saved_locator} input")
|
289
|
+
unless exists?
|
290
|
+
set_alt_locator("#{saved_locator} textarea")
|
291
|
+
set_alt_locator(saved_locator) unless exists?
|
292
|
+
end
|
218
293
|
end
|
219
294
|
value = get_value if exists?
|
220
295
|
rows.push(value)
|
@@ -238,10 +313,19 @@ module TestCentricity
|
|
238
313
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
239
314
|
set_table_cell_locator(row, column)
|
240
315
|
saved_locator = @alt_locator
|
241
|
-
|
242
|
-
|
243
|
-
set_alt_locator("#{saved_locator}//
|
244
|
-
|
316
|
+
case @locator_type
|
317
|
+
when :xpath
|
318
|
+
set_alt_locator("#{saved_locator}//input")
|
319
|
+
unless exists?
|
320
|
+
set_alt_locator("#{saved_locator}//textarea")
|
321
|
+
set_alt_locator(saved_locator) unless exists?
|
322
|
+
end
|
323
|
+
when :css
|
324
|
+
set_alt_locator("#{saved_locator} input")
|
325
|
+
unless exists?
|
326
|
+
set_alt_locator("#{saved_locator} textarea")
|
327
|
+
set_alt_locator(saved_locator) unless exists?
|
328
|
+
end
|
245
329
|
end
|
246
330
|
if exists?
|
247
331
|
value = get_value
|
@@ -291,9 +375,16 @@ module TestCentricity
|
|
291
375
|
def get_row_attribute(row, attrib)
|
292
376
|
row_count = get_row_count
|
293
377
|
raise "Row #{row} exceeds number of rows (#{row_count}) in table #{object_ref_message}" if row > row_count
|
294
|
-
|
295
|
-
|
296
|
-
|
378
|
+
case @locator_type
|
379
|
+
when :xpath
|
380
|
+
row > 1 ?
|
381
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}[#{row}]") :
|
382
|
+
set_alt_locator("#{@locator}/#{@table_body}/#{@table_row}")
|
383
|
+
when :css
|
384
|
+
row > 1 ?
|
385
|
+
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}:nth-of-type(#{row})") :
|
386
|
+
set_alt_locator("#{@locator} > #{@table_body} > #{@table_row}")
|
387
|
+
end
|
297
388
|
result = get_native_attribute(attrib)
|
298
389
|
clear_alt_locator
|
299
390
|
result
|
@@ -375,7 +466,12 @@ module TestCentricity
|
|
375
466
|
def click_header_column(column)
|
376
467
|
column_count = get_column_count
|
377
468
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
378
|
-
|
469
|
+
case @locator_type
|
470
|
+
when :xpath
|
471
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
472
|
+
when :css
|
473
|
+
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
474
|
+
end
|
379
475
|
click if exists?
|
380
476
|
clear_alt_locator
|
381
477
|
end
|
@@ -383,7 +479,12 @@ module TestCentricity
|
|
383
479
|
def get_header_column(column)
|
384
480
|
column_count = get_column_count
|
385
481
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table header #{object_ref_message}" if column > column_count
|
386
|
-
|
482
|
+
case @locator_type
|
483
|
+
when :xpath
|
484
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
485
|
+
when :css
|
486
|
+
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
487
|
+
end
|
387
488
|
value = get_value(:all) if exists?(:all)
|
388
489
|
clear_alt_locator
|
389
490
|
value
|
@@ -393,7 +494,12 @@ module TestCentricity
|
|
393
494
|
columns = []
|
394
495
|
column_count = get_column_count
|
395
496
|
(1..column_count).each do |column|
|
396
|
-
|
497
|
+
case @locator_type
|
498
|
+
when :xpath
|
499
|
+
set_alt_locator("#{@locator}//#{@table_header}/#{@header_row}/#{@header_column}[#{column}]")
|
500
|
+
when :css
|
501
|
+
set_alt_locator("#{@locator} #{@table_header} > #{@header_row} > #{@header_column}:nth-of-type(#{column})")
|
502
|
+
end
|
397
503
|
columns.push(get_value(:all)) if exists?(:all)
|
398
504
|
end
|
399
505
|
clear_alt_locator
|
@@ -406,7 +512,12 @@ module TestCentricity
|
|
406
512
|
column_count = get_column_count
|
407
513
|
raise "Column #{column} exceeds number of columns (#{column_count}) in table #{object_ref_message}" if column > column_count
|
408
514
|
set_table_cell_locator(row, column)
|
409
|
-
|
515
|
+
case @locator_type
|
516
|
+
when :xpath
|
517
|
+
set_alt_locator("#{@alt_locator}/#{@tree_expand}")
|
518
|
+
when :css
|
519
|
+
set_alt_locator("#{@alt_locator} > #{@tree_expand}")
|
520
|
+
end
|
410
521
|
expanded = true
|
411
522
|
expanded = false if exists?
|
412
523
|
clear_alt_locator
|
@@ -416,7 +527,12 @@ module TestCentricity
|
|
416
527
|
def expand_table_row(row, column)
|
417
528
|
unless is_table_row_expanded?(row, column)
|
418
529
|
set_table_cell_locator(row, column)
|
419
|
-
|
530
|
+
case @locator_type
|
531
|
+
when :xpath
|
532
|
+
set_alt_locator("#{@alt_locator}/#{@tree_expand}")
|
533
|
+
when :css
|
534
|
+
set_alt_locator("#{@alt_locator} > #{@tree_expand}")
|
535
|
+
end
|
420
536
|
click if exists?
|
421
537
|
clear_alt_locator
|
422
538
|
end
|
@@ -425,7 +541,12 @@ module TestCentricity
|
|
425
541
|
def collapse_table_row(row, column)
|
426
542
|
if is_table_row_expanded?(row, column)
|
427
543
|
set_table_cell_locator(row, column)
|
428
|
-
|
544
|
+
case @locator_type
|
545
|
+
when :xpath
|
546
|
+
set_alt_locator("#{@alt_locator}/#{@tree_collapse}")
|
547
|
+
when :css
|
548
|
+
set_alt_locator("#{@alt_locator} > #{@tree_collapse}")
|
549
|
+
end
|
429
550
|
click if exists?
|
430
551
|
clear_alt_locator
|
431
552
|
end
|
@@ -441,14 +562,26 @@ module TestCentricity
|
|
441
562
|
end
|
442
563
|
|
443
564
|
def get_table_cell_locator(row, column)
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
565
|
+
case @locator_type
|
566
|
+
when :xpath
|
567
|
+
if @table_section.nil?
|
568
|
+
row_spec = "#{@locator}/#{@table_body}/#{@table_row}"
|
569
|
+
row_spec = "#{row_spec}[#{row}]"
|
570
|
+
else
|
571
|
+
row_spec = "#{@locator}/#{@table_body}/#{@table_section}"
|
572
|
+
row_spec = "#{row_spec}[#{row}]/#{@table_row}[1]"
|
573
|
+
end
|
574
|
+
column_spec = "/#{@table_column}[#{column}]"
|
575
|
+
when :css
|
576
|
+
if @table_section.nil?
|
577
|
+
row_spec = "#{@locator} > #{@table_body} > #{@table_row}"
|
578
|
+
row_spec = "#{row_spec}:nth-of-type(#{row})"
|
579
|
+
else
|
580
|
+
row_spec = "#{@locator} > #{@table_body} > #{@table_section}"
|
581
|
+
row_spec = "#{row_spec}:nth-of-type(#{row}) > #{@table_row}:nth-of-type(1)"
|
582
|
+
end
|
583
|
+
column_spec = " > #{@table_column}:nth-of-type(#{column})"
|
450
584
|
end
|
451
|
-
column_spec = "/#{@table_column}[#{column}]"
|
452
585
|
"#{row_spec}#{column_spec}"
|
453
586
|
end
|
454
587
|
|
@@ -466,8 +599,14 @@ module TestCentricity
|
|
466
599
|
puts "Could not find table cell at #{@alt_locator}"
|
467
600
|
end
|
468
601
|
saved_locator = @alt_locator
|
469
|
-
|
470
|
-
|
602
|
+
case @locator_type
|
603
|
+
when :xpath
|
604
|
+
set_alt_locator("#{saved_locator}//input")
|
605
|
+
set_alt_locator("#{saved_locator}//textarea") unless exists?
|
606
|
+
when :css
|
607
|
+
set_alt_locator("#{saved_locator} input")
|
608
|
+
set_alt_locator("#{saved_locator} textarea") unless exists?
|
609
|
+
end
|
471
610
|
end
|
472
611
|
end
|
473
612
|
end
|