awetestlib 0.1.28 → 0.1.29pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.gitattributes +22 -22
  2. data/.gitignore +69 -69
  3. data/.yardopts +7 -7
  4. data/README.md +108 -108
  5. data/awetestlib.gemspec +57 -57
  6. data/awetestlib.windows.gemspec +41 -41
  7. data/awetestlib_notes.txt +4 -4
  8. data/awetestlib_osx.gemspec +47 -48
  9. data/bin/awetestlib +99 -99
  10. data/bin/awetestlib-android-setup.rb +26 -26
  11. data/bin/awetestlib-cucumber-setup.rb +28 -28
  12. data/bin/awetestlib-driver-setup.rb +21 -21
  13. data/bin/awetestlib-helpers.rb +41 -41
  14. data/bin/awetestlib-mobile-app-setup.rb +31 -31
  15. data/bin/awetestlib-netbeans-setup.rb +58 -58
  16. data/bin/awetestlib-regression-setup.rb +15 -15
  17. data/bin/awetestlib-rubymine-setup.rb +39 -39
  18. data/drivers/chromedriver.exe +0 -0
  19. data/ext/Rakefile +1 -1
  20. data/ext/mkrf_conf.rb +27 -27
  21. data/lib/awetestlib/html_report.rb +142 -142
  22. data/lib/awetestlib/logging.rb +366 -366
  23. data/lib/awetestlib/regression/browser.rb +1380 -1375
  24. data/lib/awetestlib/regression/drag_and_drop.rb +421 -420
  25. data/lib/awetestlib/regression/find.rb +345 -345
  26. data/lib/awetestlib/regression/legacy.rb +1187 -1187
  27. data/lib/awetestlib/regression/page_data.rb +191 -191
  28. data/lib/awetestlib/regression/runner.rb +307 -307
  29. data/lib/awetestlib/regression/tables.rb +627 -619
  30. data/lib/awetestlib/regression/user_input.rb +576 -576
  31. data/lib/awetestlib/regression/utilities.rb +1046 -988
  32. data/lib/awetestlib/regression/validations.rb +1093 -1074
  33. data/lib/awetestlib/regression/waits.rb +470 -470
  34. data/lib/awetestlib/runner.rb +18 -18
  35. data/lib/awetestlib.rb +41 -41
  36. data/lib/patches/README +2 -2
  37. data/lib/patches/firewatir.rb +106 -106
  38. data/lib/patches/watir.rb +175 -175
  39. data/lib/version.rb +2 -2
  40. data/license.txt +13 -13
  41. data/netbeans_setup.md +29 -29
  42. data/rdoc_test.bat +1 -1
  43. data/rubymine_setup.md +23 -23
  44. data/setup_samples/sample_android/features/dk.mejer.hansen.control.FlyingColorsPlayerAidActivity.apk +0 -0
  45. data/setup_samples/sample_android/features/sample_android.feature +5 -5
  46. data/setup_samples/sample_android/features/step_definitions/calabash_steps.rb +1 -1
  47. data/setup_samples/sample_android/features/support/app_installation_hooks.rb +36 -36
  48. data/setup_samples/sample_android/features/support/app_life_cycle_hooks.rb +14 -14
  49. data/setup_samples/sample_android/features/test_servers/8ba795a0288381ae346b67867b586881_0.3.2.apk +0 -0
  50. data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +76 -76
  51. data/setup_samples/sample_cucumber/features/yahoo_mail.feature +11 -11
  52. data/setup_samples/sample_mobile_app/features/my_first.feature +14 -14
  53. data/setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb +80 -80
  54. data/setup_samples/sample_mobile_app/features/support/env.rb +2 -2
  55. data/setup_samples/sample_netbeans/demo.rb +86 -86
  56. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -2
  57. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -1
  58. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +2 -2
  59. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -2
  60. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -5
  61. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -13
  62. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -5
  63. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -5
  64. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -9
  65. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -9
  66. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +4 -4
  67. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -7
  68. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -213
  69. data/setup_samples/sample_rubymine/demo.rb +86 -86
  70. data/test/create_zoho.rb +66 -66
  71. data/test/create_zoho_account1.rb +68 -68
  72. data/test/create_zoho_account2.rb +72 -72
  73. data/test/demo.rb +87 -87
  74. data/test/google_search1.rb +16 -16
  75. data/test/google_search2.rb +19 -19
  76. data/test/login_1.rb +37 -37
  77. data/test/login_1a.rb +37 -37
  78. data/test/login_2.rb +32 -32
  79. data/test/zoho_exercise.rb +21 -21
  80. data/test/zoho_util.rb +487 -487
  81. data/tmp/placeholder.html +71 -71
  82. metadata +18 -49
@@ -1,619 +1,627 @@
1
- module Awetestlib
2
- module Regression
3
- # Methods for handling Tables, Rows, and Cells
4
- # Rdoc work in progress
5
- module Tables
6
-
7
-
8
- def get_index_for_column_head(panel, table_index, strg, desc = '')
9
- table = panel.tables[table_index]
10
- get_column_index(table, strg, desc, true)
11
- end
12
-
13
- def get_column_index(table, strg, desc = '', header = false)
14
- msg1 = " header" if header
15
- msg = build_message("Get index of ", msg1, " column containing #{strg}. ", desc)
16
- rgx = Regexp.new(strg)
17
- row_idx = 0
18
- index = -1
19
- found = false
20
- table.each do |row|
21
- row_idx += 1
22
- if row.text =~ rgx
23
- col_idx = 1
24
- row.each do |cell|
25
- if cell.text =~ rgx
26
- index = col_idx
27
- found = true
28
- break
29
- end
30
- col_idx += 1
31
- end
32
- end
33
- break if found or header
34
- end
35
- if found
36
- passed_to_log("#{msg} at index #{index}.")
37
- index
38
- else
39
- failed_to_log("#{msg}")
40
- nil
41
- end
42
- rescue
43
- failed_to_log("Unable to #{msg} '#{$!}'")
44
- end
45
-
46
- # Return the index of the last row of the specified table.
47
- # @param [Watir::Table] table A reference to the table in question.
48
- # @param [Fixnum] pad The number of zeroes to prefix the index to allow correct sorting.
49
- # @param [Fixnum] every A number indicating which rows in the table actually carry data if
50
- # the table is padded with empty rows. 1 = every row, 2 = every other row, 3 = every third
51
- # row, and etc.
52
- # @return [Fixnum]
53
- def get_index_of_last_row(table, pad = 2, every = 1)
54
- index = calc_index(table.row_count, every)
55
- index = index.to_s.rjust(pad, '0')
56
- #debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
57
- index
58
- end
59
-
60
- alias get_index_for_last_row get_index_of_last_row
61
-
62
- # Return the index of the last row of the specified table containing *strg*
63
- # @param [Watir::Table] table A reference to the table in question.
64
- # @param [String, Regexp] strg A string or regular expression to search for in the table..
65
- # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
66
- # When not supplied, the entire row is searched for *strg*.
67
- # @return [Fixnum]
68
- def get_index_of_last_row_with_text(table, strg, column_index = nil)
69
- debug_to_log("#{__method__}: #{get_callers(5)}")
70
- msg1 = " in column #{column_index}" if column_index
71
- msg = build_message("Find last row in table :id=#{table.id} with text '#{strg}'", msg1)
72
- dbg = build_message("#{__method__}: #{table.id} text by row", msg1)
73
- index = 0
74
- found = false
75
- at_index = 0
76
- #row_count = table.row_count
77
- table.rows.each do |row|
78
- cell_count = get_cell_count(row)
79
- index += 1
80
- text = ''
81
- if column_index
82
- col_idx = column_index.to_i
83
- if cell_count >= col_idx
84
- text = row[col_idx].text
85
- end
86
- else
87
- text = row.text
88
- end
89
- dbg << "\n#{index}. [#{text}]"
90
- if text =~ /#{strg}/
91
- found = true
92
- at_index = index
93
- end
94
- end
95
- debug_to_log(dbg)
96
- if found
97
- passed_to_log("#{msg} at index #{index}.")
98
- at_index
99
- else
100
- failed_to_log("#{msg}")
101
- nil
102
- end
103
- rescue
104
- failed_to_log("Unable to #{msg}. '#{$!}'")
105
- end
106
-
107
- alias get_index_for_last_row_with_text get_index_of_last_row_with_text
108
-
109
- # Return the index of the _first_ row of the specified table containing *strg*
110
- # @param [Watir::Table] table A reference to the table in question.
111
- # @param [String, Regexp] strg A string or regular expression to search for in the table..
112
- # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
113
- # When not supplied, the entire row is searched for *strg*.
114
- # @param [Boolean] fail_if_found If true log a failure if *strg* _is_ found.
115
- # @return [Fixnum] the index of the row containing *strg*
116
- def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
117
- debug_to_log("#{__method__}: #{get_callers(5)}")
118
- if fail_if_found
119
- msg = 'No '
120
- else
121
- msg = 'Find '
122
- end
123
- msg << "row in table :id=#{table.id} with text '#{strg}'"
124
- msg << " in column #{column_index}" if column_index
125
- dbg = "#{__method__}: #{table.id} text by row "
126
- dbg << "in column #{column_index}" if column_index
127
- index = 0
128
- found = false
129
- table.rows.each do |row|
130
- cell_count = row.cells.length
131
- index += 1
132
- text = ''
133
- if column_index
134
- col_idx = column_index.to_i
135
- if cell_count >= col_idx
136
- text = row[col_idx].text
137
- end
138
- else
139
- text = row.text
140
- end
141
- dbg << "\n#{index}. [#{text}]"
142
- if text =~ /#{strg}/
143
- found = true
144
- break
145
- end
146
- end
147
- debug_to_log(dbg)
148
- if found
149
- if fail_if_found
150
- failed_to_log("#{msg} at index #{index}.")
151
- else
152
- passed_to_log("#{msg} at index #{index}.")
153
- end
154
- index
155
- else
156
- if fail_if_found
157
- passed_to_log("#{msg}")
158
- else
159
- failed_to_log("#{msg}")
160
- end
161
- nil
162
- end
163
- rescue
164
- failed_to_log("Unable to #{msg}. '#{$!}'")
165
- end
166
-
167
- # Return the index of the _first_ row of the specified table containing *strg* in a text field
168
- # identified by *how* and *what*.
169
- # @param [Watir::Table] table A reference to the table in question.
170
- # @param [String, Regexp] strg A string or regular expression to search for in the table..
171
- # @param [Symbol] how The element attribute used to identify the specific element.
172
- # Valid values depend on the kind of element.
173
- # Common values: :text, :id, :title, :name, :class, :href (:link only)
174
- # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
175
- # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
176
- # When not supplied, the entire row is searched for *strg*.
177
- # @return [Fixnum] the index of the row containing *strg*
178
- def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
179
- msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
180
- msg << " in column #{column_index}" if column_index
181
- index = 0
182
- found = false
183
- table.rows.each do |row|
184
- cell_count = get_cell_count(row)
185
- index += 1
186
- text = ''
187
- if column_index
188
- col_idx = column_index.to_i
189
- if cell_count >= col_idx
190
- if row[col_idx].text_field(how, what).exists?
191
- value = row[col_idx].text_field(how, what).value
192
- end
193
- end
194
- else
195
- if row.text_field(how, what).exists?
196
- value = row.text_field(how, what).value
197
- sleep(0.25)
198
- end
199
- end
200
- if value and value =~ /#{strg}/
201
- found = true
202
- break
203
- end
204
- end
205
- if found
206
- passed_to_log("#{msg} at index #{index}.")
207
- else
208
- failed_to_log("#{msg}")
209
- end
210
- index
211
- rescue
212
- failed_to_log("Unable to #{msg}. '#{$!}'")
213
- end
214
-
215
- # Return the index of a table in *browser* containing *strg*. *ordinal* indicates
216
- # whether it is the first, second, third, etc. table found with the matching text in *strg*
217
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
218
- # @param [String, Regexp] strg A string or regular expression to search for in the table..
219
- # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
220
- # @return [Fixnum] the index of the table containing *strg*
221
- def get_index_for_table_containing_text(browser, strg, ordinal = 1)
222
- msg = "Get index for table containing text '#{strg}'"
223
- index = 0
224
- found = 0
225
- browser.tables.each do |t|
226
- index += 1
227
- if t.text =~ /#{strg}/
228
- found += 1
229
- if ordinal > 0 and found == ordinal
230
- break
231
- end
232
- end
233
- end
234
- if found
235
- passed_to_log("#{msg}: #{index}")
236
- index
237
- else
238
- passed_to_log("#{msg}.")
239
- nil
240
- end
241
- rescue
242
- failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
243
- end
244
-
245
- # Return a reference to a table in *browser* containing *strg*. *ordinal* indicates
246
- # whether it is the first, second, third, etc. table found with the matching text in *strg*
247
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
248
- # @param [String, Regexp] strg A string or regular expression to search for in the table..
249
- # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
250
- # @return [Watir::Table] the table containing *strg*
251
- def get_table_containing_text(browser, strg, ordinal = 1)
252
- msg = "Get table #{ordinal} containing text '#{strg}'"
253
- index = get_index_for_table_containing_text(browser, strg, ordinal)
254
- if index
255
- passed_to_log(msg)
256
- browser.tables[index]
257
- else
258
- failed_to_log(msg)
259
- nil
260
- end
261
- rescue
262
- failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
263
- end
264
-
265
- def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
266
- rgx = Regexp.new(strg)
267
- text = ''
268
- debug_to_log("strg:'#{strg}', rgx:'#{rgx}', table_index:'#{table_index}', column_index:'#{column_index}'")
269
- nc_element.tables[table_index].each do |row|
270
- cell_count = get_cell_count(row)
271
- if cell_count >= column_index
272
- #TODO this assumes column 1 is a number column
273
- # debug_to_log("row:'#{row.cells}'")
274
- cell_1 = row[1].text
275
- if cell_1 =~ /\d+/
276
- row_text = row.text
277
- if row_text =~ rgx
278
- text = row[column_index].text
279
- break
280
- end
281
- end
282
- end
283
- end
284
- text
285
- end
286
-
287
- # Return a hash containing a cross reference of the header names and indexes (columns) for the specified table.
288
- # @example
289
- # (need example and usage)
290
- # @param [Watir::Table] table A reference to the table.
291
- # @param [Fixnum] header_index The index of the row containing the header names.
292
- # @return [Hash] Two level hash of hashes. Internal hashes are 'name' which allows look-up of a column index
293
- # by the header name, and 'index' which allows look-up of the name by the column index.
294
- def get_table_headers(table, header_index = 1)
295
- headers = Hash.new
296
- headers['index'] = Hash.new
297
- headers['name'] = Hash.new
298
- count = 1
299
- table[header_index].each do |cell|
300
- if cell.text.length > 0
301
- name = cell.text.gsub(/\s+/, ' ')
302
- headers['index'][count] = name
303
- headers['name'][name] = count
304
- end
305
- count += 1
306
- end
307
- #debug_to_log("#{__method__}: headers:\n#{headers.to_yaml}")
308
- headers
309
- rescue
310
- failed_to_log("Unable to get content headers. '#{$!}'")
311
- end
312
-
313
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
314
- def count_rows_with_string(browser, table_index, strg)
315
- hit = 0
316
- browser.tables[table_index].each do |row|
317
- if get_cell_count(row) >= 1
318
- # debug_to_log("#{__method__}: #{row.text}")
319
- #TODO this assumes column 1 is a number column
320
- if row[1].text =~ /\d+/
321
- if row.text =~ /#{strg}/i
322
- hit += 1
323
- debug_to_log("#{__method__}: #{row.text}")
324
- end
325
- end
326
- end
327
- end
328
- debug_to_log("#{__method__}: hit row count: #{hit}")
329
- hit
330
- end
331
-
332
- def fetch_array_for_table_column(nc_element, table_index, column_index)
333
- ary = []
334
- nc_element.tables[table_index].each do |row|
335
- if get_cell_count(row) >= column_index
336
- #TODO this assumes column 1 is a number column
337
- if row[1].text =~ /\d+/
338
- ary << row[column_index].text
339
- end
340
- end
341
- end
342
- return ary f
343
- end
344
-
345
- def fetch_hash_for_table_column(table, column_index, start_row = 2)
346
- hash = Hash.new
347
- row_count = 0
348
- table.each do |row|
349
- row_count += 1
350
- if get_cell_count(row) >= column_index
351
- if row_count >= start_row
352
- hash[row_count] = row[column_index].text
353
- end
354
- end
355
- end
356
- hash
357
- end
358
-
359
- def get_row_cells_text_as_array(row)
360
- ary = []
361
- row.each do |cell|
362
- ary << cell.text
363
- end
364
- ary
365
- end
366
-
367
- def count_data_rows(container, data_index, column_index)
368
- cnt = 0
369
- # get_objects(container, :tables, true)
370
- table = container.tables[data_index]
371
- dump_table_and_rows(table)
372
- if table
373
- table.rows.each do |row|
374
- if get_cell_count(row) >= column_index
375
- #TODO this assumes column 1 is a number column
376
- if row[column_index].text =~ /\d+/
377
- cnt += 1
378
- end
379
- end
380
- end
381
- end
382
- sleep_for(2)
383
- cnt
384
- end
385
-
386
- def get_cell_count(row)
387
- if $watir_script
388
- row.column_count
389
- else
390
- row.cells.length
391
- end
392
- end
393
-
394
- def exercise_sorting(browser, columnList, desc = '')
395
- #TODO put rescue inside the do loop
396
- #parameters: browser and a list of column link text values
397
- #example: exercise_sorting(browser,['Division', 'Payee', 'Date'], 'Sortable columns on this page')
398
- columnList.each do |column|
399
- click(browser, :link, :text, column, desc)
400
- end
401
- end
402
-
403
- alias validate_sorting exercise_sorting
404
-
405
- def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
406
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
407
- if not column_index
408
- column_index = get_index_for_column_head(nc_element, table_index, strg)
409
- end
410
-
411
- if column_index
412
- bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
413
- if strg =~ /date/i
414
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
415
- else
416
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
417
- end
418
-
419
- if click_text(browser, strg)
420
- if column_index
421
- sleep_for(2.5)
422
- else
423
- sleep_for(1)
424
- end
425
- act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
426
-
427
- if exp_ary == act_ary
428
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
429
- true
430
- else
431
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
432
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
433
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
434
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
435
- end
436
- end
437
- else
438
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
439
- end
440
- rescue
441
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
442
- end
443
-
444
- def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
445
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
446
-
447
- if not column_index
448
- column_index = get_index_for_column_head(browser, table_index, strg)
449
- end
450
-
451
- if column_index
452
- bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
453
- if strg =~ /date/i
454
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
455
- else
456
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
457
- end
458
-
459
- if click_text(browser, strg)
460
- sleep_for(3)
461
- act_ary = fetch_array_for_table_column(browser, table_index, column_index)
462
-
463
- if exp_ary == act_ary
464
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
465
- true
466
- else
467
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
468
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
469
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
470
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
471
- end
472
- end
473
- else
474
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
475
- end
476
- rescue
477
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
478
- end
479
-
480
- # @todo unstub
481
- # @private
482
- def verify_column_hidden(browser, panel, table_index, column_name)
483
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
484
- return true
485
- # id = @column_data_display_ids[column_name]
486
- # ok = false
487
-
488
- # row = panel.tables[2][3]
489
-
490
- # row.each do |cell|
491
- ## strg = cell.to_s
492
- ## insp = cell.inspect
493
- ## ole = cell.ole_object
494
- ## anId = cell.attribute_value(:id)
495
- # text = cell.text
496
- # if text =~ /#{id}/
497
- # if cell.to_s =~ /hidden/
498
- # passed_to_log( "Column '#{column_name}' is hidden.")
499
- # else
500
- # failed_to_log( "Column '#{column_name}' is not hidden.")
501
- # end
502
- # ok = true
503
- # end
504
- # end
505
- # if not ok
506
- # failed_to_log( "Column '#{column_name}' not found.")
507
- # end
508
- # rescue
509
- # failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
510
- end
511
-
512
- # @todo unstub
513
- # @private
514
- def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
515
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
516
- return true
517
-
518
- row = browser.tables[data_index][row_index]
519
- # debug_to_log( "#{row.to_a}")
520
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
521
- act_ary = get_row_cells_text_as_array(row)
522
-
523
- if not act_ary.include?(column_name)
524
- passed_to_log("Column '#{column_name}' is hidden.")
525
- else
526
- failed_to_log("Column '#{column_name}' is not hidden.")
527
- end
528
- end
529
-
530
- # @todo unstub
531
- # @private
532
- def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
533
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
534
- return true
535
-
536
- row = browser.tables[data_index][row_index]
537
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
538
- act_ary = get_row_cells_text_as_array(row)
539
-
540
- if act_ary.include?(column_name)
541
- passed_to_log("Column '#{column_name}' is visible.")
542
- else
543
- failed_to_log("Column '#{column_name}' is not visible.")
544
- end
545
- end
546
-
547
- # @todo unstub
548
- # @private
549
- def verify_column_visible(browser, panel, table_index, column_name)
550
-
551
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
552
- return true
553
-
554
- # id = @column_data_display_ids[column_name]
555
- # ok = false
556
- # row = panel.tables[table_index][1]
557
- # row.each do |cell|
558
- # if cell.id == id
559
- # if not cell.to_s =~ /hidden/
560
- # passed_to_log("Column '#{column_name}' is visible.")
561
- # else
562
- # failed_to_log("Column '#{column_name}' is not visible.")
563
- # end
564
- # ok = true
565
- # end
566
- # end
567
- # if not ok
568
- # failed_to_log("Column '#{column_name}' not found.")
569
- # end
570
- rescue
571
- failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
572
- end
573
-
574
- # Verify that a table's columns are in the expected order by header names. The table is identified by its *index*
575
- # within the container *browser*.
576
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
577
- def verify_column_order(browser, table_index, header_index, exp_ary)
578
- mark_testlevel("Begin #{__method__.to_s.titleize}", 0)
579
- row = browser.tables[table_index][header_index]
580
- act_ary = get_row_cells_text_as_array(row)
581
-
582
- if exp_ary == act_ary
583
- passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
584
- else
585
- failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
586
- end
587
- mark_testlevel("End #{__method__.to_s.titleize}", 0)
588
- end
589
-
590
- def text_in_table?(browser, how, what, expected, desc = '')
591
- msg = build_message("Table :#{how}=>#{what} contains '#{expected}.", desc)
592
- if browser.table(how, what).text =~ expected
593
- passed_to_log(msg)
594
- true
595
- else
596
- failed_to_log(msg)
597
- end
598
- rescue
599
- failed_to_log("Unable to verify that #{msg}': '#{$!}'")
600
- end
601
-
602
- def text_in_table_row_with_text?(table, text, target, desc = '')
603
- #TODO This needs clarification, renaming
604
- msg = build_message("Table :id=>#{table.id} row with text '#{text} also contains '#{target}.", desc)
605
- index = get_index_of_row_with_text(table, text)
606
- if table[index].text =~ target
607
- passed_to_log(msg)
608
- true
609
- else
610
- failed_to_log(msg)
611
- end
612
- end
613
-
614
- alias verify_text_in_table_with_text text_in_table_row_with_text?
615
-
616
- end
617
- end
618
- end
619
-
1
+ module Awetestlib
2
+ module Regression
3
+ # Methods for handling Tables, Rows, and Cells
4
+ # Rdoc work in progress
5
+ module Tables
6
+
7
+
8
+ def get_index_for_column_head(panel, table_index, strg, desc = '')
9
+ table = panel.tables[table_index]
10
+ get_column_index(table, strg, desc, true)
11
+ end
12
+
13
+ def get_column_index(table, strg, desc = '', header = false)
14
+ msg1 = " header" if header
15
+ msg = build_message("Get index of ", msg1, " column containing #{strg}. ", desc)
16
+ rgx = Regexp.new(strg)
17
+ row_idx = 0
18
+ index = -1
19
+ found = false
20
+ table.each do |row|
21
+ row_idx += 1
22
+ if row.text =~ rgx
23
+ col_idx = 1
24
+ row.each do |cell|
25
+ if cell.text =~ rgx
26
+ index = col_idx
27
+ found = true
28
+ break
29
+ end
30
+ col_idx += 1
31
+ end
32
+ end
33
+ break if found or header
34
+ end
35
+ if found
36
+ passed_to_log("#{msg} at index #{index}.")
37
+ index
38
+ else
39
+ failed_to_log("#{msg}")
40
+ nil
41
+ end
42
+ rescue
43
+ failed_to_log("Unable to #{msg} '#{$!}'")
44
+ end
45
+
46
+ # Return the index of the last row of the specified table.
47
+ # @param [Watir::Table] table A reference to the table in question.
48
+ # @param [Fixnum] pad The number of zeroes to prefix the index to allow correct sorting.
49
+ # @param [Fixnum] every A number indicating which rows in the table actually carry data if
50
+ # the table is padded with empty rows. 1 = every row, 2 = every other row, 3 = every third
51
+ # row, and etc.
52
+ # @return [Fixnum]
53
+ def get_index_of_last_row(table, pad = 2, every = 1)
54
+ index = calc_index(table.row_count, every)
55
+ index = index.to_s.rjust(pad, '0')
56
+ #debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
57
+ index
58
+ end
59
+
60
+ alias get_index_for_last_row get_index_of_last_row
61
+
62
+ # Return the index of the last row of the specified table containing *strg*
63
+ # @param [Watir::Table] table A reference to the table in question.
64
+ # @param [String, Regexp] strg A string or regular expression to search for in the table..
65
+ # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
66
+ # When not supplied, the entire row is searched for *strg*.
67
+ # @return [Fixnum]
68
+ def get_index_of_last_row_with_text(table, strg, column_index = nil)
69
+ debug_to_log("#{__method__}: #{get_callers(5)}")
70
+ msg1 = " in column #{column_index}" if column_index
71
+ msg = build_message("Find last row in table :id=#{table.id} with text '#{strg}'", msg1)
72
+ dbg = build_message("#{__method__}: #{table.id} text by row", msg1)
73
+ index = 0
74
+ found = false
75
+ at_index = 0
76
+ #row_count = table.row_count
77
+ table.rows.each do |row|
78
+ cell_count = get_cell_count(row)
79
+ index += 1
80
+ text = ''
81
+ if column_index
82
+ col_idx = column_index.to_i
83
+ if cell_count >= col_idx
84
+ text = row[col_idx].text
85
+ end
86
+ else
87
+ text = row.text
88
+ end
89
+ dbg << "\n#{index}. [#{text}]"
90
+ if text =~ /#{strg}/
91
+ found = true
92
+ at_index = index
93
+ end
94
+ end
95
+ debug_to_log(dbg)
96
+ if found
97
+ passed_to_log("#{msg} at index #{index}.")
98
+ at_index
99
+ else
100
+ failed_to_log("#{msg}")
101
+ nil
102
+ end
103
+ rescue
104
+ failed_to_log("Unable to #{msg}. '#{$!}'")
105
+ end
106
+
107
+ alias get_index_for_last_row_with_text get_index_of_last_row_with_text
108
+
109
+ # Return the index of the _first_ row of the specified table containing *strg*
110
+ # @param [Watir::Table] table A reference to the table in question.
111
+ # @param [String, Regexp] strg A string or regular expression to search for in the table..
112
+ # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
113
+ # When not supplied, the entire row is searched for *strg*.
114
+ # @param [Boolean] fail_if_found If true log a failure if *strg* _is_ found.
115
+ # @param [Fixnum] after_index Forces method to accept hit on *strg* only if it occurs
116
+ # after the row indicated by this argument. When omitted, the first hit is accepted.
117
+ # @return [Fixnum] the index of the row containing *strg*
118
+ def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false, after_index = nil)
119
+ debug_to_log("#{__method__}: #{get_callers(5)}")
120
+ if fail_if_found
121
+ msg = 'No '
122
+ else
123
+ msg = 'Find '
124
+ end
125
+ msg << "row in table :id=#{table.id} with text '#{strg}'"
126
+ msg << " in column #{column_index}" if column_index
127
+ dbg = "#{__method__}: #{table.id} text by row "
128
+ dbg << "in column #{column_index}" if column_index
129
+ index = 0
130
+ found = false
131
+ table.rows.each do |row|
132
+ cell_count = row.cells.length
133
+ index += 1
134
+ text = ''
135
+ if column_index
136
+ col_idx = column_index.to_i
137
+ if cell_count >= col_idx
138
+ text = row[col_idx].text
139
+ end
140
+ else
141
+ text = row.text
142
+ end
143
+ dbg << "\n#{index}. [#{text}]"
144
+ if text =~ /#{strg}/
145
+ if after_index and index > after_index
146
+ found = true
147
+ break
148
+ else
149
+ found = true
150
+ break
151
+ end
152
+ end
153
+ end
154
+ debug_to_log(dbg)
155
+ if found
156
+ if fail_if_found
157
+ failed_to_log("#{msg} at index #{index}.")
158
+ else
159
+ passed_to_log("#{msg} at index #{index}.")
160
+ end
161
+ index
162
+ else
163
+ if fail_if_found
164
+ passed_to_log("#{msg}")
165
+ else
166
+ failed_to_log("#{msg}")
167
+ end
168
+ nil
169
+ end
170
+ rescue
171
+ failed_to_log("Unable to #{msg}. '#{$!}'")
172
+ end
173
+
174
+ # Return the index of the _first_ row of the specified table containing *strg* in a text field
175
+ # identified by *how* and *what*.
176
+ # @param [Watir::Table] table A reference to the table in question.
177
+ # @param [String, Regexp] strg A string or regular expression to search for in the table..
178
+ # @param [Symbol] how The element attribute used to identify the specific element.
179
+ # Valid values depend on the kind of element.
180
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
181
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
182
+ # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
183
+ # When not supplied, the entire row is searched for *strg*.
184
+ # @return [Fixnum] the index of the row containing *strg*
185
+ def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
186
+ msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
187
+ msg << " in column #{column_index}" if column_index
188
+ index = 0
189
+ found = false
190
+ table.rows.each do |row|
191
+ cell_count = get_cell_count(row)
192
+ index += 1
193
+ text = ''
194
+ if column_index
195
+ col_idx = column_index.to_i
196
+ if cell_count >= col_idx
197
+ if row[col_idx].text_field(how, what).exists?
198
+ value = row[col_idx].text_field(how, what).value
199
+ end
200
+ end
201
+ else
202
+ if row.text_field(how, what).exists?
203
+ value = row.text_field(how, what).value
204
+ sleep(0.25)
205
+ end
206
+ end
207
+ if value and value =~ /#{strg}/
208
+ found = true
209
+ break
210
+ end
211
+ end
212
+ if found
213
+ passed_to_log("#{msg} at index #{index}.")
214
+ else
215
+ failed_to_log("#{msg}")
216
+ end
217
+ index
218
+ rescue
219
+ failed_to_log("Unable to #{msg}. '#{$!}'")
220
+ end
221
+
222
+ # Return the index of a table in *browser* containing *strg*. *ordinal* indicates
223
+ # whether it is the first, second, third, etc. table found with the matching text in *strg*
224
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
225
+ # @param [String, Regexp] strg A string or regular expression to search for in the table..
226
+ # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
227
+ # @return [Fixnum] the index of the table containing *strg*
228
+ def get_index_for_table_containing_text(browser, strg, ordinal = 1)
229
+ msg = "Get index for table containing text '#{strg}'"
230
+ index = 0
231
+ found = 0
232
+ browser.tables.each do |t|
233
+ index += 1
234
+ if t.text =~ /#{strg}/
235
+ found += 1
236
+ if ordinal > 0 and found == ordinal
237
+ break
238
+ end
239
+ end
240
+ end
241
+ if found
242
+ passed_to_log("#{msg}: #{index}")
243
+ index
244
+ else
245
+ passed_to_log("#{msg}.")
246
+ nil
247
+ end
248
+ rescue
249
+ failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
250
+ end
251
+
252
+ # Return a reference to a table in *browser* containing *strg*. *ordinal* indicates
253
+ # whether it is the first, second, third, etc. table found with the matching text in *strg*
254
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
255
+ # @param [String, Regexp] strg A string or regular expression to search for in the table..
256
+ # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
257
+ # @return [Watir::Table] the table containing *strg*
258
+ def get_table_containing_text(browser, strg, ordinal = 1)
259
+ msg = "Get table #{ordinal} containing text '#{strg}'"
260
+ index = get_index_for_table_containing_text(browser, strg, ordinal)
261
+ if index
262
+ passed_to_log(msg)
263
+ browser.tables[index]
264
+ else
265
+ failed_to_log(msg)
266
+ nil
267
+ end
268
+ rescue
269
+ failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
270
+ end
271
+
272
+ def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
273
+ rgx = Regexp.new(strg)
274
+ text = ''
275
+ debug_to_log("strg:'#{strg}', rgx:'#{rgx}', table_index:'#{table_index}', column_index:'#{column_index}'")
276
+ nc_element.tables[table_index].each do |row|
277
+ cell_count = get_cell_count(row)
278
+ if cell_count >= column_index
279
+ #TODO this assumes column 1 is a number column
280
+ # debug_to_log("row:'#{row.cells}'")
281
+ cell_1 = row[1].text
282
+ if cell_1 =~ /\d+/
283
+ row_text = row.text
284
+ if row_text =~ rgx
285
+ text = row[column_index].text
286
+ break
287
+ end
288
+ end
289
+ end
290
+ end
291
+ text
292
+ end
293
+
294
+ # Return a hash containing a cross reference of the header names and indexes (columns) for the specified table.
295
+ # @example
296
+ # (need example and usage)
297
+ # @param [Watir::Table] table A reference to the table.
298
+ # @param [Fixnum] header_index The index of the row containing the header names.
299
+ # @return [Hash] Two level hash of hashes. Internal hashes are 'name' which allows look-up of a column index
300
+ # by the header name, and 'index' which allows look-up of the name by the column index.
301
+ def get_table_headers(table, header_index = 1)
302
+ headers = Hash.new
303
+ headers['index'] = Hash.new
304
+ headers['name'] = Hash.new
305
+ count = 1
306
+ table[header_index].each do |cell|
307
+ if cell.text.length > 0
308
+ name = cell.text.gsub(/\s+/, ' ')
309
+ headers['index'][count] = name
310
+ headers['name'][name] = count
311
+ end
312
+ count += 1
313
+ end
314
+ #debug_to_log("#{__method__}: headers:\n#{headers.to_yaml}")
315
+ headers
316
+ rescue
317
+ failed_to_log("Unable to get content headers. '#{$!}'")
318
+ end
319
+
320
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
321
+ def count_rows_with_string(browser, table_index, strg)
322
+ hit = 0
323
+ browser.tables[table_index].each do |row|
324
+ if get_cell_count(row) >= 1
325
+ # debug_to_log("#{__method__}: #{row.text}")
326
+ #TODO this assumes column 1 is a number column
327
+ if row[1].text =~ /\d+/
328
+ if row.text =~ /#{strg}/i
329
+ hit += 1
330
+ debug_to_log("#{__method__}: #{row.text}")
331
+ end
332
+ end
333
+ end
334
+ end
335
+ debug_to_log("#{__method__}: hit row count: #{hit}")
336
+ hit
337
+ end
338
+
339
+ def fetch_array_for_table_column(table, column_index, start_row = 2)
340
+ ary = []
341
+ row_count = 0
342
+ table.each do |row|
343
+ row_count += 1
344
+ if get_cell_count(row) >= column_index
345
+ if row_count >= start_row
346
+ ary << row[column_index].text
347
+ end
348
+ end
349
+ end
350
+ ary
351
+ end
352
+
353
+ def fetch_hash_for_table_column(table, column_index, start_row = 2)
354
+ hash = Hash.new
355
+ row_count = 0
356
+ table.each do |row|
357
+ row_count += 1
358
+ if get_cell_count(row) >= column_index
359
+ if row_count >= start_row
360
+ hash[row_count] = row[column_index].text
361
+ end
362
+ end
363
+ end
364
+ hash
365
+ end
366
+
367
+ def get_row_cells_text_as_array(row)
368
+ ary = []
369
+ row.each do |cell|
370
+ ary << cell.text
371
+ end
372
+ ary
373
+ end
374
+
375
+ def count_data_rows(container, data_index, column_index)
376
+ cnt = 0
377
+ # get_objects(container, :tables, true)
378
+ table = container.tables[data_index]
379
+ dump_table_and_rows(table)
380
+ if table
381
+ table.rows.each do |row|
382
+ if get_cell_count(row) >= column_index
383
+ #TODO this assumes column 1 is a number column
384
+ if row[column_index].text =~ /\d+/
385
+ cnt += 1
386
+ end
387
+ end
388
+ end
389
+ end
390
+ sleep_for(2)
391
+ cnt
392
+ end
393
+
394
+ def get_cell_count(row)
395
+ if $watir_script
396
+ row.column_count
397
+ else
398
+ row.cells.length
399
+ end
400
+ end
401
+
402
+ def exercise_sorting(browser, columnList, desc = '')
403
+ #TODO put rescue inside the do loop
404
+ #parameters: browser and a list of column link text values
405
+ #example: exercise_sorting(browser,['Division', 'Payee', 'Date'], 'Sortable columns on this page')
406
+ columnList.each do |column|
407
+ click(browser, :link, :text, column, desc)
408
+ end
409
+ end
410
+
411
+ alias validate_sorting exercise_sorting
412
+
413
+ def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
414
+ mark_testlevel("Verify Column Sort '#{strg}'", 3)
415
+ if not column_index
416
+ column_index = get_index_for_column_head(nc_element, table_index, strg)
417
+ end
418
+
419
+ if column_index
420
+ bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
421
+ if strg =~ /date/i
422
+ exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
423
+ else
424
+ exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
425
+ end
426
+
427
+ if click_text(browser, strg)
428
+ if column_index
429
+ sleep_for(2.5)
430
+ else
431
+ sleep_for(1)
432
+ end
433
+ act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
434
+
435
+ if exp_ary == act_ary
436
+ passed_to_log("Click on column '#{strg}' produces expected sorted list.")
437
+ true
438
+ else
439
+ failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
440
+ debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
441
+ debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
442
+ debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
443
+ end
444
+ end
445
+ else
446
+ failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
447
+ end
448
+ rescue
449
+ failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
450
+ end
451
+
452
+ def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
453
+ mark_testlevel("Verify Column Sort '#{strg}'", 3)
454
+
455
+ if not column_index
456
+ column_index = get_index_for_column_head(browser, table_index, strg)
457
+ end
458
+
459
+ if column_index
460
+ bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
461
+ if strg =~ /date/i
462
+ exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
463
+ else
464
+ exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
465
+ end
466
+
467
+ if click_text(browser, strg)
468
+ sleep_for(3)
469
+ act_ary = fetch_array_for_table_column(browser, table_index, column_index)
470
+
471
+ if exp_ary == act_ary
472
+ passed_to_log("Click on column '#{strg}' produces expected sorted list.")
473
+ true
474
+ else
475
+ failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
476
+ debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
477
+ debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
478
+ debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
479
+ end
480
+ end
481
+ else
482
+ failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
483
+ end
484
+ rescue
485
+ failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
486
+ end
487
+
488
+ # @todo unstub
489
+ # @private
490
+ def verify_column_hidden(browser, panel, table_index, column_name)
491
+ passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
492
+ return true
493
+ # id = @column_data_display_ids[column_name]
494
+ # ok = false
495
+
496
+ # row = panel.tables[2][3]
497
+
498
+ # row.each do |cell|
499
+ ## strg = cell.to_s
500
+ ## insp = cell.inspect
501
+ ## ole = cell.ole_object
502
+ ## anId = cell.attribute_value(:id)
503
+ # text = cell.text
504
+ # if text =~ /#{id}/
505
+ # if cell.to_s =~ /hidden/
506
+ # passed_to_log( "Column '#{column_name}' is hidden.")
507
+ # else
508
+ # failed_to_log( "Column '#{column_name}' is not hidden.")
509
+ # end
510
+ # ok = true
511
+ # end
512
+ # end
513
+ # if not ok
514
+ # failed_to_log( "Column '#{column_name}' not found.")
515
+ # end
516
+ # rescue
517
+ # failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
518
+ end
519
+
520
+ # @todo unstub
521
+ # @private
522
+ def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
523
+ passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
524
+ return true
525
+
526
+ row = browser.tables[data_index][row_index]
527
+ # debug_to_log( "#{row.to_a}")
528
+ #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
529
+ act_ary = get_row_cells_text_as_array(row)
530
+
531
+ if not act_ary.include?(column_name)
532
+ passed_to_log("Column '#{column_name}' is hidden.")
533
+ else
534
+ failed_to_log("Column '#{column_name}' is not hidden.")
535
+ end
536
+ end
537
+
538
+ # @todo unstub
539
+ # @private
540
+ def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
541
+ passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
542
+ return true
543
+
544
+ row = browser.tables[data_index][row_index]
545
+ #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
546
+ act_ary = get_row_cells_text_as_array(row)
547
+
548
+ if act_ary.include?(column_name)
549
+ passed_to_log("Column '#{column_name}' is visible.")
550
+ else
551
+ failed_to_log("Column '#{column_name}' is not visible.")
552
+ end
553
+ end
554
+
555
+ # @todo unstub
556
+ # @private
557
+ def verify_column_visible(browser, panel, table_index, column_name)
558
+
559
+ passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
560
+ return true
561
+
562
+ # id = @column_data_display_ids[column_name]
563
+ # ok = false
564
+ # row = panel.tables[table_index][1]
565
+ # row.each do |cell|
566
+ # if cell.id == id
567
+ # if not cell.to_s =~ /hidden/
568
+ # passed_to_log("Column '#{column_name}' is visible.")
569
+ # else
570
+ # failed_to_log("Column '#{column_name}' is not visible.")
571
+ # end
572
+ # ok = true
573
+ # end
574
+ # end
575
+ # if not ok
576
+ # failed_to_log("Column '#{column_name}' not found.")
577
+ # end
578
+ rescue
579
+ failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
580
+ end
581
+
582
+ # Verify that a table's columns are in the expected order by header names. The table is identified by its *index*
583
+ # within the container *browser*.
584
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
585
+ def verify_column_order(browser, table_index, header_index, exp_ary)
586
+ mark_testlevel("Begin #{__method__.to_s.titleize}", 0)
587
+ row = browser.tables[table_index][header_index]
588
+ act_ary = get_row_cells_text_as_array(row)
589
+
590
+ if exp_ary == act_ary
591
+ passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
592
+ else
593
+ failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
594
+ end
595
+ mark_testlevel("End #{__method__.to_s.titleize}", 0)
596
+ end
597
+
598
+ def text_in_table?(browser, how, what, expected, desc = '')
599
+ msg = build_message("Table :#{how}=>#{what} contains '#{expected}.", desc)
600
+ if browser.table(how, what).text =~ expected
601
+ passed_to_log(msg)
602
+ true
603
+ else
604
+ failed_to_log(msg)
605
+ end
606
+ rescue
607
+ failed_to_log("Unable to verify that #{msg}': '#{$!}'")
608
+ end
609
+
610
+ def text_in_table_row_with_text?(table, text, target, desc = '')
611
+ #TODO This needs clarification, renaming
612
+ msg = build_message("Table :id=>#{table.id} row with text '#{text} also contains '#{target}.", desc)
613
+ index = get_index_of_row_with_text(table, text)
614
+ if table[index].text =~ target
615
+ passed_to_log(msg)
616
+ true
617
+ else
618
+ failed_to_log(msg)
619
+ end
620
+ end
621
+
622
+ alias verify_text_in_table_with_text text_in_table_row_with_text?
623
+
624
+ end
625
+ end
626
+ end
627
+