awetestlib 0.1.22-x86-mingw32 → 0.1.23-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,9 +17,11 @@ require 'active_support/inflector'
17
17
 
18
18
  module Awetestlib
19
19
  module Regression
20
+ # Collects all the components needed to run the script and executes it.
20
21
  class Runner < Awetestlib::Runner
21
22
 
22
23
  # order matters here
24
+ include ActiveSupport::Inflector
23
25
  include Awetestlib::Logging
24
26
  include Awetestlib::Regression::Utilities
25
27
  include Awetestlib::Regression::Browser
@@ -97,12 +99,15 @@ module Awetestlib
97
99
  @myName = File.basename(options[:script_file]).sub(/\.rb$/, '')
98
100
 
99
101
  if options[:output_to_log]
100
- log_path = "#{@myRoot}/"
101
- log_path << "#{options[:log_path_subdir]}/" if options[:log_path_subdir]
102
- log_spec = File.join log_path, "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log"
102
+ log_name = "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log"
103
+ if options[:log_path_subdir]
104
+ FileUtils.mkdir options[:log_path_subdir] unless File.directory? options[:log_path_subdir]
105
+ log_path = options[:log_path_subdir]
106
+ log_spec = File.join(log_path, log_name)
107
+ else
108
+ log_spec = log_name
109
+ end
103
110
  @myLog = init_logger(log_spec, @myName)
104
- #@start_timestamp = Time.now
105
- #start_to_log(@start_timestamp)
106
111
  end
107
112
 
108
113
  if options[:xls_path]
@@ -280,7 +285,6 @@ module Awetestlib
280
285
  finish_run
281
286
  @report_class.finish_report(@html_report_file)
282
287
  open_report_file
283
- #finish_run
284
288
  @myLog.close if @myLog
285
289
  end
286
290
 
@@ -5,18 +5,14 @@ module Awetestlib
5
5
  module Tables
6
6
 
7
7
 
8
- # Groups: Columns, Rows, Sorting
9
-
10
8
  def get_index_for_column_head(panel, table_index, strg, desc = '')
11
9
  table = panel.tables[table_index]
12
10
  get_column_index(table, strg, desc, true)
13
11
  end
14
12
 
15
13
  def get_column_index(table, strg, desc = '', header = false)
16
- msg = "Get index of "
17
- msg << " header" if header
18
- msg << " column containing #{strg}. "
19
- msg << " #{desc}" if desc.length > 0
14
+ msg1 = " header" if header
15
+ msg = build_message("Get index of ", msg1, " column containing #{strg}. ", desc)
20
16
  rgx = Regexp.new(strg)
21
17
  row_idx = 0
22
18
  index = -1
@@ -47,6 +43,13 @@ module Awetestlib
47
43
  failed_to_log("Unable to #{msg} '#{$!}'")
48
44
  end
49
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]
50
53
  def get_index_of_last_row(table, pad = 2, every = 1)
51
54
  index = calc_index(table.row_count, every)
52
55
  index = index.to_s.rjust(pad, '0')
@@ -56,12 +59,17 @@ module Awetestlib
56
59
 
57
60
  alias get_index_for_last_row get_index_of_last_row
58
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]
59
68
  def get_index_of_last_row_with_text(table, strg, column_index = nil)
60
69
  debug_to_log("#{__method__}: #{get_callers(5)}")
61
- msg = "Find last row in table :id=#{table.id} with text '#{strg}'"
62
- msg << " in column #{column_index}" if column_index
63
- dbg = "#{__method__}: #{table.id} text by row "
64
- dbg << "in column #{column_index}" if column_index
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)
65
73
  index = 0
66
74
  found = false
67
75
  at_index = 0
@@ -98,6 +106,13 @@ module Awetestlib
98
106
 
99
107
  alias get_index_for_last_row_with_text get_index_of_last_row_with_text
100
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*
101
116
  def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
102
117
  debug_to_log("#{__method__}: #{get_callers(5)}")
103
118
  if fail_if_found
@@ -149,6 +164,17 @@ module Awetestlib
149
164
  failed_to_log("Unable to #{msg}. '#{$!}'")
150
165
  end
151
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*
152
178
  def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
153
179
  msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
154
180
  msg << " in column #{column_index}" if column_index
@@ -186,6 +212,12 @@ module Awetestlib
186
212
  failed_to_log("Unable to #{msg}. '#{$!}'")
187
213
  end
188
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*
189
221
  def get_index_for_table_containing_text(browser, strg, ordinal = 1)
190
222
  msg = "Get index for table containing text '#{strg}'"
191
223
  index = 0
@@ -210,6 +242,12 @@ module Awetestlib
210
242
  failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
211
243
  end
212
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*
213
251
  def get_table_containing_text(browser, strg, ordinal = 1)
214
252
  msg = "Get table #{ordinal} containing text '#{strg}'"
215
253
  index = get_index_for_table_containing_text(browser, strg, ordinal)
@@ -272,9 +310,10 @@ module Awetestlib
272
310
  failed_to_log("Unable to get content headers. '#{$!}'")
273
311
  end
274
312
 
275
- def count_rows_with_string(container, table_index, strg)
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)
276
315
  hit = 0
277
- container.tables[table_index].each do |row|
316
+ browser.tables[table_index].each do |row|
278
317
  if get_cell_count(row) >= 1
279
318
  # debug_to_log("#{__method__}: #{row.text}")
280
319
  #TODO this assumes column 1 is a number column
@@ -345,11 +384,11 @@ module Awetestlib
345
384
  end
346
385
 
347
386
  def get_cell_count(row)
348
- # if @browserAbbrev == 'IE' or $use_firewatir
349
- row.cells.length
350
- # else
351
- # row.cell_count
352
- # end
387
+ if $watir_script
388
+ row.column_count
389
+ else
390
+ row.cells.length
391
+ end
353
392
  end
354
393
 
355
394
  def exercise_sorting(browser, columnList, desc = '')
@@ -438,7 +477,8 @@ module Awetestlib
438
477
  failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
439
478
  end
440
479
 
441
- #TODO unstub
480
+ # @todo unstub
481
+ # @private
442
482
  def verify_column_hidden(browser, panel, table_index, column_name)
443
483
  passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
444
484
  return true
@@ -469,7 +509,8 @@ module Awetestlib
469
509
  # failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
470
510
  end
471
511
 
472
- #TODO unstub
512
+ # @todo unstub
513
+ # @private
473
514
  def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
474
515
  passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
475
516
  return true
@@ -486,7 +527,8 @@ module Awetestlib
486
527
  end
487
528
  end
488
529
 
489
- #TODO unstub
530
+ # @todo unstub
531
+ # @private
490
532
  def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
491
533
  passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
492
534
  return true
@@ -502,7 +544,8 @@ module Awetestlib
502
544
  end
503
545
  end
504
546
 
505
- #TODO unstub
547
+ # @todo unstub
548
+ # @private
506
549
  def verify_column_visible(browser, panel, table_index, column_name)
507
550
 
508
551
  passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
@@ -528,9 +571,12 @@ module Awetestlib
528
571
  failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
529
572
  end
530
573
 
531
- def verify_column_order(browser, table_index, row_index, exp_ary)
532
- mark_testlevel("Verify Column Order", 2)
533
- row = browser.tables[table_index][row_index]
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]
534
580
  act_ary = get_row_cells_text_as_array(row)
535
581
 
536
582
  if exp_ary == act_ary
@@ -538,7 +584,7 @@ module Awetestlib
538
584
  else
539
585
  failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
540
586
  end
541
- sleep_for(1)
587
+ mark_testlevel("End #{__method__.to_s.titleize}", 0)
542
588
  end
543
589
 
544
590
  def text_in_table?(browser, how, what, expected, desc = '')