awetestlib 0.1.29pre4-x86-mingw32 → 0.1.29-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Awetestlib
2
2
  module Regression
3
3
  # Methods for moving and resizing elements, manipulating the mouse, and checking for relative positioning of elements,
4
4
  # including overlap, overlay, etc.
5
- # @note Still experimental. Works with IE but not fully tested with Firefox or Chrome in Windows using Watir-webdriver.
5
+ # @note Still experimental. Works with IE but not fully tested with Firefox or Chrome in Windows.
6
6
  # Not compatible with Mac
7
7
  # Rdoc is work in progress
8
8
  module DragAndDrop
@@ -284,9 +284,8 @@ module Awetestlib
284
284
  [x, y, w, h]
285
285
  end
286
286
 
287
- def drag_and_drop_div(browser, how, what, delta_x, delta_y, desc = '')
287
+ def drag_and_drop(browser, how, what, delta_x, delta_y, desc = '')
288
288
  #TODO: webdriver
289
- #TODO: assumes element is div
290
289
  msg = "Drag and drop element :#{how}=>#{what} by x=>#{delta_x} y=>#{delta_y}."
291
290
  msg << " #{desc}" if desc.length > 0
292
291
  drag_me = browser.div(how, what)
@@ -294,7 +293,7 @@ module Awetestlib
294
293
  passed_to_log(msg)
295
294
  true
296
295
  rescue
297
- failed_to_log(unable_to)
296
+ failed_to_log("Unable to #{msg} '#{$!}'")
298
297
  end
299
298
 
300
299
  def drag_and_drop(x1, y1, dx, dy, speed=nil)
@@ -14,6 +14,7 @@ require 'awetestlib/html_report'
14
14
  require 'ostruct'
15
15
  require 'active_support'
16
16
  require 'active_support/inflector'
17
+ require 'sys/uname'
17
18
 
18
19
  module Awetestlib
19
20
  module Regression
@@ -21,6 +22,7 @@ module Awetestlib
21
22
  class Runner < Awetestlib::Runner
22
23
 
23
24
  # order matters here
25
+ include Sys
24
26
  include ActiveSupport::Inflector
25
27
  include Awetestlib::Logging
26
28
  include Awetestlib::Regression::Utilities
@@ -216,9 +218,6 @@ module Awetestlib
216
218
 
217
219
  def require_gems
218
220
 
219
- require 'sys/uname'
220
- include Sys
221
-
222
221
  case @targetBrowser.abbrev
223
222
 
224
223
  when 'IE'
@@ -112,10 +112,8 @@ module Awetestlib
112
112
  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
113
113
  # When not supplied, the entire row is searched for *strg*.
114
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
115
  # @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)
116
+ def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
119
117
  debug_to_log("#{__method__}: #{get_callers(5)}")
120
118
  if fail_if_found
121
119
  msg = 'No '
@@ -142,13 +140,8 @@ module Awetestlib
142
140
  end
143
141
  dbg << "\n#{index}. [#{text}]"
144
142
  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
143
+ found = true
144
+ break
152
145
  end
153
146
  end
154
147
  debug_to_log(dbg)
@@ -336,18 +329,17 @@ module Awetestlib
336
329
  hit
337
330
  end
338
331
 
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
332
+ def fetch_array_for_table_column(nc_element, table_index, column_index)
333
+ ary = []
334
+ nc_element.tables[table_index].each do |row|
344
335
  if get_cell_count(row) >= column_index
345
- if row_count >= start_row
336
+ #TODO this assumes column 1 is a number column
337
+ if row[1].text =~ /\d+/
346
338
  ary << row[column_index].text
347
339
  end
348
340
  end
349
341
  end
350
- ary
342
+ return ary f
351
343
  end
352
344
 
353
345
  def fetch_hash_for_table_column(table, column_index, start_row = 2)
@@ -487,7 +487,7 @@ module Awetestlib
487
487
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output. Required in this method.
488
488
  # @param [String] valid_value The expected value of the text field, e.g., following reformatting.
489
489
  # @return (see #click)
490
- def set_text_field_and_validate(browser, how, what, value, valid_value = nil, desc ='')
490
+ def set_text_field_and_validate(browser, how, what, value, desc, valid_value = nil)
491
491
  #NOTE: use when value and valid_value differ as with dollar reformatting
492
492
  if set_text_field(browser, how, what, value, desc, true)
493
493
  expected = valid_value ? valid_value : value
@@ -59,31 +59,6 @@ module Awetestlib
59
59
  msg
60
60
  end
61
61
 
62
- def get_date_names(date = Date.today)
63
- this_month = date.month
64
- if this_month == 12
65
- next_month = 1
66
- else
67
- next_month = this_month + 1
68
- end
69
- if this_month == 1
70
- prev_month = 12
71
- else
72
- prev_month = this_month - 1
73
- end
74
-
75
- month_arr = ['', 'January', 'February', 'March', 'April', 'May', 'June',
76
- 'July', 'August', 'September', 'October', 'November', 'December']
77
-
78
- this_month_name = month_arr[this_month]
79
- next_month_name = month_arr[next_month]
80
- prev_month_name = month_arr[prev_month]
81
-
82
- arr = [date.year, date.day, this_month_name, next_month_name, prev_month_name]
83
- debug_to_log("#{__method__} #{nice_array(arr)}")
84
- arr
85
- end
86
-
87
62
  def get_trace(lnbr)
88
63
  callertrace = "\nCaller trace: (#{lnbr})\n"
89
64
  Kernel.caller.each_index do |x|
@@ -311,41 +286,14 @@ module Awetestlib
311
286
  else
312
287
  new_arr = arr
313
288
  end
314
- "['#{new_arr.join("', '")}']"
315
- end
316
-
317
- def nice_number(number, decimals = 0, dollars = false)
318
- number.to_s.gsub!(/[,\$]/, '')
319
- ptrn = "%0.#{decimals}f"
320
- ptrn = '$' + ptrn if dollars
321
- sprintf(ptrn, number).gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
289
+ "['#{new_arr.join("','")}']"
322
290
  end
323
291
 
324
- def pad_date(dt)
325
- if dt and dt.length > 0
326
- a, d1, b, d2, c = dt.split(/([\/\.-])/)
327
- a = a.rjust(2, '0') unless a and a.length > 1
328
- b = b.rjust(2, '0') unless b and b.length > 1
329
- c = c.rjust(2, '0') unless c and c.length > 1
330
- a + d1 + b + d2 + c
331
- else
332
- ''
333
- end
334
- end
335
-
336
292
  def string_count_in_string(strg, substrg)
337
293
  count = strg.scan(substrg).length
338
294
  count
339
295
  end
340
296
 
341
- def strip_regex_mix(strg)
342
- rslt = strg.dup
343
- while match = rslt.match(/(\(\?-mix:(.+)\))/)
344
- rslt.sub!(match[1], "/#{match[2]}/")
345
- end
346
- rslt
347
- end
348
-
349
297
  def rescue_me(e, me = nil, what = nil, where = nil, who = nil)
350
298
  #TODO: these are rescues from exceptions raised in Watir/Firewatir
351
299
  debug_to_log("#{__method__}: Begin rescue")
@@ -543,14 +491,14 @@ module Awetestlib
543
491
  tables.each do |tbl|
544
492
  tbl_cnt += 1
545
493
  row_cnt = 0
546
- msg <<"\n=================\ntable: #{tbl_cnt}\n=================\n#{tbl}\ntext:\n#{tbl.text}"
494
+ msg << "\n=================\ntable: #{tbl_cnt}\n=================\n#{tbl}\ntext:\n#{tbl.text}"
547
495
  tbl.rows.each do |row|
548
496
  row_cnt += 1
549
497
  cell_cnt = 0
550
- msg <<"\n=================\ntable: #{tbl_cnt} row: #{row_cnt}\n#{row.inspect}\n#{row}\ntext:'#{row.text}'"
498
+ msg << "\n=================\ntable: #{tbl_cnt} row: #{row_cnt}\n#{row.inspect}\n#{row}\ntext:'#{row.text}'"
551
499
  row.each do |cell|
552
500
  cell_cnt += 1
553
- msg <<"\ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
501
+ msg << " \ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
554
502
  end
555
503
  end
556
504
  end
@@ -579,14 +527,14 @@ module Awetestlib
579
527
  def dump_table_rows_and_cells(tbl)
580
528
  msg = ''
581
529
  row_cnt = 0
582
- msg <<"\n=================\ntable: #{tbl.inspect}\n=================\n#{tbl}\ntext:\n#{tbl.text}"
530
+ msg << "\n=================\ntable: #{tbl.inspect}\n=================\n#{tbl}\ntext:\n#{tbl.text}"
583
531
  tbl.rows.each do |row|
584
532
  row_cnt += 1
585
533
  cell_cnt = 0
586
- msg <<"\n=================\nrow: #{row_cnt}\n#{row.inspect}\n#{row}\ntext:'#{row.text}'"
534
+ msg << "\n=================\nrow: #{row_cnt}\n#{row.inspect}\n#{row}\ntext:'#{row.text}'"
587
535
  row.each do |cell|
588
536
  cell_cnt += 1
589
- msg <<"\ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
537
+ msg << "\ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
590
538
  end
591
539
  end
592
540
  debug_to_log(msg)
@@ -597,10 +545,10 @@ module Awetestlib
597
545
  def dump_row_cells(row)
598
546
  msg = ''
599
547
  cell_cnt = 0
600
- msg <<"\n=================\nrow: #{row.inspect}\n#{row}\ntext:'#{row.text}'"
548
+ msg << "\n=================\nrow: #{row.inspect}\n#{row}\ntext:'#{row.text}'"
601
549
  row.each do |cell|
602
550
  cell_cnt += 1
603
- msg <<"\ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
551
+ msg << "\ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
604
552
  end
605
553
  debug_to_log(msg)
606
554
  end
@@ -886,10 +834,14 @@ module Awetestlib
886
834
  #method for handling file upload dialog
887
835
  #use click_no_wait on the action that triggers the save dialog
888
836
  # TODO need version for Firefox
889
- def file_upload(filepath, title = 'Choose File', text = '', button = '&Open',
890
- control = 'Edit1', side = 'primary')
891
- title = translate_popup_title(title)
892
- msg = "Window title=#{title} button='#{button}' text='#{text}' side='#{side}':"
837
+ def file_upload(filepath)
838
+ title = 'Choose File'
839
+ title = translate_popup_title(title)
840
+ text = ''
841
+ button = "&Open"
842
+ control = "Edit1"
843
+ side = 'primary'
844
+ msg = "Window title=#{title} button='#{button}' text='#{text}' side='#{side}':"
893
845
  begin
894
846
  if @ai.WinWait(title, text, WAIT)
895
847
  passed_to_log("#{msg} found.")
@@ -900,10 +852,7 @@ module Awetestlib
900
852
  passed_to_log("#{msg} #{control} command sent.")
901
853
  sleep_for 1
902
854
  if @ai.ControlClick(title, text, button, "primary")
903
-
904
855
  passed_to_log("#{msg} Upload of #{filepath} succeeded.")
905
-
906
-
907
856
  else
908
857
  failed_to_log("#{msg} Upload of #{filepath} failed. (#{__LINE__})")
909
858
  end
@@ -989,12 +938,10 @@ module Awetestlib
989
938
  debug_to_log("#{__method__}: #{method} #{$!}")
990
939
  end
991
940
 
992
- def unable_to(message = '', no_dolbang = false, verify_that = false)
941
+ def unable_to(message = '', no_dolbang = false)
993
942
  call_arr = get_call_array()
994
943
  call_script, call_line, call_meth = parse_caller(call_arr[1])
995
- strg = "Unable to"
996
- strg << " verify" if verify_that
997
- strg << " #{call_meth.titleize}:"
944
+ strg = "Unable to #{call_meth.titleize}:"
998
945
  strg << " #{message}" if message.length > 0
999
946
  strg << " '#{$!}'" unless no_dolbang
1000
947
  strg
@@ -1035,19 +982,14 @@ module Awetestlib
1035
982
  [arr.length, arr]
1036
983
  end
1037
984
 
1038
- def awetestlib?
1039
- not Awetestlib::Runner.nil?
1040
- rescue
1041
- return false
1042
- end
1043
985
 
1044
986
  def get_os
1045
987
  @os = OpenStruct.new(
1046
- :name => Uname.sysname,
1047
- :version => Uname.version,
1048
- :release => Uname.release,
1049
- :nodename => Uname.nodename,
1050
- :machine => Uname.machine
988
+ :name => Sys::Uname.sysname,
989
+ :version => Sys::Uname.version,
990
+ :release => Sys::Uname.release,
991
+ :nodename => Sys::Uname.nodename,
992
+ :machine => Sys::Uname.machine
1051
993
  )
1052
994
  end
1053
995