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