awetestlib 0.1.3-x86-mingw32 → 0.1.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/awetestlib.windows.gemspec +1 -1
  2. data/bin/awetestlib +11 -4
  3. data/bin/awetestlib-helpers.rb +28 -1
  4. data/bin/awetestlib-netbeans-setup.rb +39 -0
  5. data/bin/awetestlib-rubymine-setup.rb +33 -0
  6. data/images/logo.png +0 -0
  7. data/lib/awetestlib/html_report.rb +171 -0
  8. data/lib/{regression → awetestlib}/logging.rb +10 -43
  9. data/lib/awetestlib/regression/browser.rb +1233 -0
  10. data/lib/awetestlib/regression/drag_and_drop.rb +379 -0
  11. data/lib/awetestlib/regression/find.rb +431 -0
  12. data/lib/awetestlib/regression/legacy.rb +45 -0
  13. data/lib/awetestlib/regression/page_data.rb +190 -0
  14. data/lib/awetestlib/regression/runner.rb +306 -0
  15. data/lib/awetestlib/regression/tables.rb +491 -0
  16. data/lib/awetestlib/regression/user_input.rb +1256 -0
  17. data/lib/awetestlib/regression/utilities.rb +895 -0
  18. data/lib/awetestlib/regression/validations.rb +1184 -0
  19. data/lib/awetestlib/regression/waits.rb +391 -0
  20. data/lib/awetestlib/runner.rb +16 -0
  21. data/lib/awetestlib.rb +4 -4
  22. data/lib/version.rb +2 -2
  23. data/setup_samples/sample_netbeans/demo.rb +86 -0
  24. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -0
  25. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -0
  26. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +1 -0
  27. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -0
  28. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -0
  29. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -0
  30. data/setup_samples/sample_rubymine/.idea/.name +1 -0
  31. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -0
  32. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -0
  33. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -0
  34. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -0
  35. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +5 -0
  36. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -0
  37. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -0
  38. data/setup_samples/sample_rubymine/demo.rb +86 -0
  39. metadata +44 -19
  40. data/lib/regression/browser.rb +0 -1259
  41. data/lib/regression/drag_and_drop.rb +0 -374
  42. data/lib/regression/find.rb +0 -426
  43. data/lib/regression/legacy.rb +0 -40
  44. data/lib/regression/page_data.rb +0 -185
  45. data/lib/regression/runner.rb +0 -278
  46. data/lib/regression/tables.rb +0 -486
  47. data/lib/regression/user_input.rb +0 -1255
  48. data/lib/regression/utilities.rb +0 -891
  49. data/lib/regression/validations.rb +0 -1179
  50. data/lib/regression/waits.rb +0 -387
@@ -1,486 +0,0 @@
1
- module Tables
2
-
3
- def get_index_for_column_head(panel, table_index, strg)
4
- rgx = Regexp.new(strg)
5
- panel.tables[table_index].each do |row|
6
- if row.text =~ rgx
7
- index = 1
8
- row.each do |cell|
9
- if cell.text =~ rgx
10
- return index
11
- end
12
- index += 1
13
- end
14
- end
15
- end
16
- end
17
-
18
- def get_index_of_last_row(table, pad = 2, every = 1)
19
- index = calc_index(table.row_count, every)
20
- index = index.to_s.rjust(pad, '0')
21
- #debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
22
- index
23
- end
24
-
25
- alias get_index_for_last_row get_index_of_last_row
26
-
27
- def get_index_of_last_row_with_text(table, strg, column_index = nil)
28
- debug_to_log("#{__method__}: #{get_callers(5)}")
29
- msg = "Find last row in table :id=#{table.id} with text '#{strg}'"
30
- msg << " in column #{column_index}" if column_index
31
- dbg = "#{__method__}: #{table.id} text by row "
32
- dbg << "in column #{column_index}" if column_index
33
- index = 0
34
- found = false
35
- at_index = 0
36
- #row_count = table.row_count
37
- table.rows.each do |row|
38
- cell_count = get_cell_count(row)
39
- index += 1
40
- text = ''
41
- if column_index
42
- col_idx = column_index.to_i
43
- if cell_count >= col_idx
44
- text = row[col_idx].text
45
- end
46
- else
47
- text = row.text
48
- end
49
- dbg << "\n#{index}. [#{text}]"
50
- if text =~ /#{strg}/
51
- found = true
52
- at_index = index
53
- end
54
- end
55
- debug_to_log(dbg)
56
- if found
57
- passed_to_log("#{msg} at index #{index}.")
58
- at_index
59
- else
60
- failed_to_log("#{msg}")
61
- nil
62
- end
63
- rescue
64
- failed_to_log("Unable to #{msg}. '#{$!}'")
65
- end
66
-
67
- alias get_index_for_last_row_with_text get_index_of_last_row_with_text
68
-
69
- def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
70
- debug_to_log("#{__method__}: #{get_callers(5)}")
71
- if fail_if_found
72
- msg = 'No '
73
- else
74
- msg = 'Find '
75
- end
76
- msg << "row in table :id=#{table.id} with text '#{strg}'"
77
- msg << " in column #{column_index}" if column_index
78
- dbg = "#{__method__}: #{table.id} text by row "
79
- dbg << "in column #{column_index}" if column_index
80
- index = 0
81
- found = false
82
- table.rows.each do |row|
83
- cell_count = row.cells.length
84
- index += 1
85
- text = ''
86
- if column_index
87
- col_idx = column_index.to_i
88
- if cell_count >= col_idx
89
- text = row[col_idx].text
90
- end
91
- else
92
- text = row.text
93
- end
94
- dbg << "\n#{index}. [#{text}]"
95
- if text =~ /#{strg}/
96
- found = true
97
- break
98
- end
99
- end
100
- debug_to_log(dbg)
101
- if found
102
- if fail_if_found
103
- failed_to_log("#{msg} at index #{index}.")
104
- else
105
- passed_to_log("#{msg} at index #{index}.")
106
- end
107
- index
108
- else
109
- if fail_if_found
110
- passed_to_log("#{msg}")
111
- else
112
- failed_to_log("#{msg}")
113
- end
114
- nil
115
- end
116
- rescue
117
- failed_to_log("Unable to #{msg}. '#{$!}'")
118
- end
119
-
120
- def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
121
- msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
122
- msg << " in column #{column_index}" if column_index
123
- index = 0
124
- found = false
125
- table.rows.each do |row|
126
- cell_count = get_cell_count(row)
127
- index += 1
128
- text = ''
129
- if column_index
130
- col_idx = column_index.to_i
131
- if cell_count >= col_idx
132
- if row[col_idx].text_field(how, what).exists?
133
- value = row[col_idx].text_field(how, what).value
134
- end
135
- end
136
- else
137
- if row.text_field(how, what).exists?
138
- value = row.text_field(how, what).value
139
- sleep(0.25)
140
- end
141
- end
142
- if value and value =~ /#{strg}/
143
- found = true
144
- break
145
- end
146
- end
147
- if found
148
- passed_to_log("#{msg} at index #{index}.")
149
- else
150
- failed_to_log("#{msg}")
151
- end
152
- index
153
- rescue
154
- failed_to_log("Unable to #{msg}. '#{$!}'")
155
- end
156
-
157
- def get_index_for_table_containing_text(browser, strg, ordinal = 1)
158
- msg = "Get index for table containing text '#{strg}'"
159
- index = 0
160
- found = 0
161
- browser.tables.each do |t|
162
- index += 1
163
- if t.text =~ /#{strg}/
164
- found += 1
165
- if ordinal > 0 and found == ordinal
166
- break
167
- end
168
- end
169
- end
170
- if found
171
- passed_to_log("#{msg}: #{index}")
172
- index
173
- else
174
- passed_to_log("#{msg}.")
175
- nil
176
- end
177
- rescue
178
- failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
179
- end
180
-
181
- def get_table_containing_text(browser, strg, ordinal = 1)
182
- msg = "Get table #{ordinal} containing text '#{strg}'"
183
- index = get_index_for_table_containing_text(browser, strg, ordinal)
184
- if index
185
- passed_to_log(msg)
186
- browser.tables[index]
187
- else
188
- failed_to_log(msg)
189
- nil
190
- end
191
- rescue
192
- failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
193
- end
194
-
195
- def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
196
- rgx = Regexp.new(strg)
197
- text = ''
198
- debug_to_log("strg:'#{strg}', rgx:'#{rgx}', table_index:'#{table_index}', column_index:'#{column_index}'")
199
- nc_element.tables[table_index].each do |row|
200
- cell_count = get_cell_count(row)
201
- if cell_count >= column_index
202
- #TODO this assumes column 1 is a number column
203
- # debug_to_log("row:'#{row.cells}'")
204
- cell_1 = row[1].text
205
- if cell_1 =~ /\d+/
206
- row_text = row.text
207
- if row_text =~ rgx
208
- text = row[column_index].text
209
- break
210
- end
211
- end
212
- end
213
- end
214
- text
215
- end
216
-
217
- def count_rows_with_string(container, table_index, strg)
218
- hit = 0
219
- container.tables[table_index].each do |row|
220
- if get_cell_count(row) >= 1
221
- # debug_to_log("#{__method__}: #{row.text}")
222
- #TODO this assumes column 1 is a number column
223
- if row[1].text =~ /\d+/
224
- if row.text =~ /#{strg}/i
225
- hit += 1
226
- debug_to_log("#{__method__}: #{row.text}")
227
- end
228
- end
229
- end
230
- end
231
- debug_to_log("#{__method__}: hit row count: #{hit}")
232
- hit
233
- end
234
-
235
- def fetch_array_for_table_column(nc_element, table_index, column_index)
236
- ary = []
237
- nc_element.tables[table_index].each do |row|
238
- if get_cell_count(row) >= column_index
239
- #TODO this assumes column 1 is a number column
240
- if row[1].text =~ /\d+/
241
- ary << row[column_index].text
242
- end
243
- end
244
- end
245
- return ary f
246
- end
247
-
248
- def fetch_hash_for_table_column(table, column_index, start_row = 2)
249
- hash = Hash.new
250
- row_count = 0
251
- table.each do |row|
252
- row_count += 1
253
- if get_cell_count(row) >= column_index
254
- if row_count >= start_row
255
- hash[row_count] = row[column_index].text
256
- end
257
- end
258
- end
259
- hash
260
- end
261
-
262
- def get_row_cells_text_as_array(row)
263
- ary = []
264
- row.each do |cell|
265
- ary << cell.text
266
- end
267
- ary
268
- end
269
-
270
- def count_data_rows(container, data_index, column_index)
271
- cnt = 0
272
- # get_objects(container, :tables, true)
273
- table = container.tables[data_index]
274
- dump_table_and_rows(table)
275
- if table
276
- table.rows.each do |row|
277
- if get_cell_count(row) >= column_index
278
- #TODO this assumes column 1 is a number column
279
- if row[column_index].text =~ /\d+/
280
- cnt += 1
281
- end
282
- end
283
- end
284
- end
285
- sleep_for(2)
286
- cnt
287
- end
288
-
289
- def get_cell_count(row)
290
- # if @browserAbbrev == 'IE' or $use_firewatir
291
- row.cells.length
292
- # else
293
- # row.cell_count
294
- # end
295
- end
296
-
297
- def exercise_sorting(browser, columnList, desc = '')
298
- #TODO put rescue inside the do loop
299
- #parameters: browser and a list of column link text values
300
- #example: exercise_sorting(browser,['Division', 'Payee', 'Date'], 'Sortable columns on this page')
301
- columnList.each do |column|
302
- click(browser, :link, :text, column, desc)
303
- end
304
- end
305
-
306
- alias validate_sorting exercise_sorting
307
-
308
- def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
309
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
310
- if not column_index
311
- column_index = get_index_for_column_head(nc_element, table_index, strg)
312
- end
313
-
314
- if column_index
315
- bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
316
- if strg =~ /date/i
317
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
318
- else
319
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
320
- end
321
-
322
- if click_text(browser, strg)
323
- if column_index
324
- sleep_for(2.5)
325
- else
326
- sleep_for(1)
327
- end
328
- act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
329
-
330
- if exp_ary == act_ary
331
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
332
- true
333
- else
334
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
335
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
336
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
337
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
338
- end
339
- end
340
- else
341
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
342
- end
343
- rescue
344
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
345
- end
346
-
347
- def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
348
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
349
-
350
- if not column_index
351
- column_index = get_index_for_column_head(browser, table_index, strg)
352
- end
353
-
354
- if column_index
355
- bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
356
- if strg =~ /date/i
357
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
358
- else
359
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
360
- end
361
-
362
- if click_text(browser, strg)
363
- sleep_for(3)
364
- act_ary = fetch_array_for_table_column(browser, table_index, column_index)
365
-
366
- if exp_ary == act_ary
367
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
368
- true
369
- else
370
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
371
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
372
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
373
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
374
- end
375
- end
376
- else
377
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
378
- end
379
- rescue
380
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
381
- end
382
-
383
- #TODO unstub
384
- def verify_column_hidden(browser, panel, table_index, column_name)
385
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
386
- return true
387
- # id = @column_data_display_ids[column_name]
388
- # ok = false
389
-
390
- # row = panel.tables[2][3]
391
-
392
- # row.each do |cell|
393
- ## strg = cell.to_s
394
- ## insp = cell.inspect
395
- ## ole = cell.ole_object
396
- ## anId = cell.attribute_value(:id)
397
- # text = cell.text
398
- # if text =~ /#{id}/
399
- # if cell.to_s =~ /hidden/
400
- # passed_to_log( "Column '#{column_name}' is hidden.")
401
- # else
402
- # failed_to_log( "Column '#{column_name}' is not hidden.")
403
- # end
404
- # ok = true
405
- # end
406
- # end
407
- # if not ok
408
- # failed_to_log( "Column '#{column_name}' not found.")
409
- # end
410
- # rescue
411
- # failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
412
- end
413
-
414
- #TODO unstub
415
- def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
416
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
417
- return true
418
-
419
- row = browser.tables[data_index][row_index]
420
- # debug_to_log( "#{row.to_a}")
421
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
422
- act_ary = get_row_cells_text_as_array(row)
423
-
424
- if not act_ary.include?(column_name)
425
- passed_to_log("Column '#{column_name}' is hidden.")
426
- else
427
- failed_to_log("Column '#{column_name}' is not hidden.")
428
- end
429
- end
430
-
431
- #TODO unstub
432
- def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
433
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
434
- return true
435
-
436
- row = browser.tables[data_index][row_index]
437
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
438
- act_ary = get_row_cells_text_as_array(row)
439
-
440
- if act_ary.include?(column_name)
441
- passed_to_log("Column '#{column_name}' is visible.")
442
- else
443
- failed_to_log("Column '#{column_name}' is not visible.")
444
- end
445
- end
446
-
447
- #TODO unstub
448
- def verify_column_visible(browser, panel, table_index, column_name)
449
-
450
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
451
- return true
452
-
453
- # id = @column_data_display_ids[column_name]
454
- # ok = false
455
- # row = panel.tables[table_index][1]
456
- # row.each do |cell|
457
- # if cell.id == id
458
- # if not cell.to_s =~ /hidden/
459
- # passed_to_log("Column '#{column_name}' is visible.")
460
- # else
461
- # failed_to_log("Column '#{column_name}' is not visible.")
462
- # end
463
- # ok = true
464
- # end
465
- # end
466
- # if not ok
467
- # failed_to_log("Column '#{column_name}' not found.")
468
- # end
469
- rescue
470
- failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
471
- end
472
-
473
- def verify_column_order(browser, table_index, row_index, exp_ary)
474
- mark_testlevel("Verify Column Order", 2)
475
- row = browser.tables[table_index][row_index]
476
- act_ary = get_row_cells_text_as_array(row)
477
-
478
- if exp_ary == act_ary
479
- passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
480
- else
481
- failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
482
- end
483
- sleep_for(1)
484
- end
485
-
486
- end