awetestlib 0.0.2-x86-mingw32 → 0.0.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/regression/legacy.rb +258 -150
  2. data/lib/version.rb +2 -2
  3. metadata +4 -4
@@ -10,9 +10,9 @@ module Legacy
10
10
  raise
11
11
  end
12
12
 
13
- #TODO replace with method_missing?
14
- # place holder to prevent method not found error in scripts
13
+ # Place holder to prevent method not found error in scripts
15
14
  def set_script_variables
15
+ # TODO: replace with method_missing?
16
16
  end
17
17
 
18
18
  def setup
@@ -51,6 +51,7 @@ module Legacy
51
51
  @y_tolerance = 4
52
52
  end
53
53
 
54
+ # :category: Waits
54
55
  def sleep_for(seconds, dbg = true, desc = '')
55
56
  msg = "Sleeping for #{seconds} seconds."
56
57
  msg << " #{desc}" if desc.length > 0
@@ -59,15 +60,18 @@ module Legacy
59
60
  sleep(seconds)
60
61
  end
61
62
 
63
+ # :category: Helpers
62
64
  def get_mdyy(t = Time.now)
63
65
  "#{t.month}/#{t.day}/#{t.year}"
64
66
  end
65
67
 
68
+ # :category: Helpers
66
69
  def get_prefix(strg, offset)
67
70
  a_slice = strg.slice(0, offset)
68
71
  a_slice.downcase
69
72
  end
70
73
 
74
+ # :category: Helpers
71
75
  def get_timestamp(format = 'long', offset = nil, offset_unit = :years)
72
76
  t = DateTime.now
73
77
  if offset
@@ -99,41 +103,19 @@ module Legacy
99
103
  end
100
104
  end
101
105
 
106
+ # :category: Helpers
102
107
  def calc_index(index, every = 1)
103
108
  (index / every) + (every - 1)
104
109
  end
105
110
 
106
111
  =begin rdoc
107
- tags: data, DOM, page
108
- browser is any container element. Best to use is the smallest that contains the desired data.
109
- types defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio
110
- Set types to array of subset if fewer elements are desired.
111
- returns a single hash:
112
- ---
113
- :name:
114
- :span: {}
115
- :textarea: {}
116
- :radio: {}
117
- :checkbox: {}
118
- :hidden: {}
119
- :select_list: {}
120
- :text: {}
121
- :index:
122
- :span: {}
123
- :textarea: {}
124
- :radio: {}
125
- :checkbox: {}
126
- :hidden: {}
127
- :select_list: {}
128
- :text: {}
129
- :id:
130
- :span: {}
131
- :textarea: {}
132
- :radio: {}
133
- :checkbox: {}
134
- :hidden: {}
135
- :select_list: {}
136
- :text: {}
112
+ :category: Page Data
113
+ :tags: data, DOM, page
114
+
115
+ *browser* is any container element. Best to use is the smallest that contains the desired data.
116
+
117
+ *types* defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio.
118
+ Set types to array of subset of these if fewer elements are desired.
137
119
 
138
120
  No positive validations are reported but failure is rescued and reported.
139
121
  =end
@@ -173,14 +155,21 @@ No positive validations are reported but failure is rescued and reported.
173
155
  end
174
156
 
175
157
  =begin rdoc
176
- tags: data, DOM
177
- data is output of capture_page_data().
178
- how is one of :id, :name, :index
179
- what is the target value for how
180
- type is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
181
- get_text is used for select_list to choose selected option value or text (default)
182
- note that multiple selections will be captured as arrays so value and text.
183
- Not tested with multiple selections (02aug2011)
158
+ :category: Page Data
159
+ :tags:data, DOM
160
+
161
+ *data* is output of capture_page_data().
162
+
163
+ *how* is one of :id, :name, :index
164
+
165
+ *what* is the target value for how
166
+
167
+ *type* is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
168
+
169
+ *get_text* is used for select_list to choose selected option value or text (default)
170
+
171
+ Note that multiple selections will be captured as arrays so value and text.
172
+
184
173
  =end
185
174
  def fetch_page_data(data, how, what, type, get_text = true)
186
175
  rslt = data[how][type][what]
@@ -195,6 +184,7 @@ Not tested with multiple selections (02aug2011)
195
184
  rslt
196
185
  end
197
186
 
187
+ # :category: Helpers
198
188
  def capture_screen(browser, ts)
199
189
  browser.maximize
200
190
  browser.bring_to_front
@@ -210,6 +200,7 @@ Not tested with multiple selections (02aug2011)
210
200
  screenfile
211
201
  end
212
202
 
203
+ # :category: Helpers
213
204
  def bail_out(browser, lnbr, msg)
214
205
  ts = Time.new
215
206
  msg = "Bailing out at util line #{lnbr} #{ts} " + msg
@@ -231,6 +222,7 @@ Not tested with multiple selections (02aug2011)
231
222
  raise(RuntimeError, msg, caller)
232
223
  end
233
224
 
225
+ # :category: Helpers
234
226
  def parse_cookies(browser)
235
227
  cookies = Hash.new
236
228
  strg = browser.document.cookie
@@ -243,13 +235,20 @@ Not tested with multiple selections (02aug2011)
243
235
  end
244
236
 
245
237
  =begin rdoc
246
- tags: data, DOM
247
- browser is any container element. best to use is the smallest that contains the desired data.
248
- type is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
249
- returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
250
- a given element appears once in the set of hashes depending on how is is found: id first
238
+ :category: Page Data
239
+ :tags:data, DOM
240
+
241
+ *browser* is any container element. best to use is the smallest that contains the desired data.
242
+
243
+ *type* is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
244
+
245
+ Returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
246
+
247
+ A given element appears once in the set of hashes depending on how is is found: id first
251
248
  then name, then index.
252
- select list value is in the form 'value::text'. parse with x.split('::')
249
+
250
+ Select list value is in the form 'value::text'. parse with x.split('::')
251
+
253
252
  No positive validations are reported but failure is rescued and reported.
254
253
  =end
255
254
  def parse_elements(browser, type)
@@ -299,6 +298,7 @@ No positive validations are reported but failure is rescued and reported.
299
298
  failed_to_log("#{__method__}: '#{$!}'")
300
299
  end
301
300
 
301
+ # :category: GUI
302
302
  def verify_no_element_overlap(browser, above_element, above_how, above_what, below_element, below_how, below_what, side, desc = '')
303
303
  mark_testlevel("#{__method__.to_s.titleize}", 3)
304
304
  msg = "#{above_element.to_s.titleize} #{above_how}=>#{above_what} does not overlap "+
@@ -316,6 +316,7 @@ No positive validations are reported but failure is rescued and reported.
316
316
  failed_to_log("Unable to verify that #{msg} '#{$!}'")
317
317
  end
318
318
 
319
+ # :category: GUI
319
320
  def verify_element_inside(inner_element, outer_element, desc = '')
320
321
  mark_testlevel("#{__method__.to_s.titleize}", 3)
321
322
  msg = "#{inner_element.class.to_s} (:id=#{inner_element.id}) is fully enclosed by #{outer_element.class.to_s} (:id=#{outer_element.id})."
@@ -330,6 +331,7 @@ No positive validations are reported but failure is rescued and reported.
330
331
  failed_to_log("Unable to verify that #{msg} '#{$!}'")
331
332
  end
332
333
 
334
+ # :category: GUI
333
335
  def overlay?(inner, outer, side = :bottom)
334
336
  #mark_testlevel("#{__method__.to_s.titleize}", 3)
335
337
  inner_t, inner_b, inner_l, inner_r = inner.bounding_rectangle_offsets
@@ -360,6 +362,7 @@ No positive validations are reported but failure is rescued and reported.
360
362
  failed_to_log("Unable to determine overlay. '#{$!}'")
361
363
  end
362
364
 
365
+ # :category: Page Data
363
366
  def pdf_to_text(file, noblank = true)
364
367
  spec = file.sub(/\.pdf$/, '')
365
368
  `pdftotext #{spec}.pdf`
@@ -375,6 +378,7 @@ No positive validations are reported but failure is rescued and reported.
375
378
  text
376
379
  end
377
380
 
381
+ # :category: Bullet-Proofing
378
382
  def kill_browser(hwnd, lnbr, browser = nil, doflag = false)
379
383
  # TODO Firefox
380
384
  logit = false
@@ -411,6 +415,7 @@ No positive validations are reported but failure is rescued and reported.
411
415
  end
412
416
  end
413
417
 
418
+ # :category: Bullet-Proofing
414
419
  def do_taskkill(severity, pid)
415
420
  if pid and pid > 0 and pid < 538976288
416
421
  info_to_log("Executing taskkill for pid #{pid}")
@@ -420,6 +425,7 @@ No positive validations are reported but failure is rescued and reported.
420
425
  error_to_log("#{$!} (#{__LINE__})")
421
426
  end
422
427
 
428
+ # :category: Bullet-Proofing
423
429
  def check_for_other_browsers
424
430
  cnt1 = find_other_browsers
425
431
  cnt2 = Watir::Process.count 'iexplore.exe'
@@ -428,6 +434,7 @@ No positive validations are reported but failure is rescued and reported.
428
434
  error_to_log("#{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}")
429
435
  end
430
436
 
437
+ # :category: Bullet-Proofing
431
438
  def check_for_and_clear_other_browsers
432
439
  if @targetBrowser.abbrev == 'IE'
433
440
  debug_to_log("#{__method__}:")
@@ -467,29 +474,32 @@ No positive validations are reported but failure is rescued and reported.
467
474
  error_to_log("#{__method__}: #{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}")
468
475
  end
469
476
 
470
- #def attach_browser(browser, how, what)
471
- # debug_to_log("Attaching browser window :#{how}=>'#{what}' ")
472
- # uri_decoded_pattern = URI.encode(what.to_s.gsub('(?-mix:', '').gsub(')', ''))
473
- # case @browserAbbrev
474
- # when 'IE'
475
- # tmpbrowser = Watir::IE.attach(how, what)
476
- # browser.visible = true
477
- # tmpbrowser.visible = true
478
- # tmpbrowser.speed = :fast
479
- # tmpbrowser
480
- # when 'FF'
481
- # tmpbrowser = FireWatir::Firefox.attach(how, /#{uri_decoded_pattern}/)
482
- # when 'S'
483
- # Watir::Safari.attach(how, what)
484
- # tmpbrowser = browser
485
- # when 'C'
486
- # browser.window(how, /#{uri_decoded_pattern}/).use
487
- # tmpbrowser = browser
488
- # end
489
- # debug_to_log("#{__method__}: tmpbrowser:#{tmpbrowser.inspect}")
490
- # tmpbrowser
491
- #end
492
- #
477
+ #--
478
+ #def attach_browser(browser, how, what)
479
+ # debug_to_log("Attaching browser window :#{how}=>'#{what}' ")
480
+ # uri_decoded_pattern = URI.encode(what.to_s.gsub('(?-mix:', '').gsub(')', ''))
481
+ # case @browserAbbrev
482
+ # when 'IE'
483
+ # tmpbrowser = Watir::IE.attach(how, what)
484
+ # browser.visible = true
485
+ # tmpbrowser.visible = true
486
+ # tmpbrowser.speed = :fast
487
+ # tmpbrowser
488
+ # when 'FF'
489
+ # tmpbrowser = FireWatir::Firefox.attach(how, /#{uri_decoded_pattern}/)
490
+ # when 'S'
491
+ # Watir::Safari.attach(how, what)
492
+ # tmpbrowser = browser
493
+ # when 'C'
494
+ # browser.window(how, /#{uri_decoded_pattern}/).use
495
+ # tmpbrowser = browser
496
+ # end
497
+ # debug_to_log("#{__method__}: tmpbrowser:#{tmpbrowser.inspect}")
498
+ # tmpbrowser
499
+ #end
500
+ #++
501
+
502
+ # :category: Navigation
493
503
  def attach_browser(browser, how, what, desc = '')
494
504
  debug_to_log("Attaching browser window :#{how}=>'#{what}' #{desc}")
495
505
  uri_decoded_pattern = URI.encode(what.to_s.gsub('(?-mix:', '').gsub(')', ''))
@@ -519,12 +529,14 @@ No positive validations are reported but failure is rescued and reported.
519
529
  tmpbrowser
520
530
  end
521
531
 
532
+ # :category: Navigation
522
533
  def attach_browser_by_url(browser, pattern, desc = '')
523
534
  attach_browser(browser, :url, pattern, desc)
524
535
  end
525
536
 
526
537
  alias attach_browser_with_url attach_browser_by_url
527
538
 
539
+ # :category: Navigation
528
540
  def attach_popup(browser, how, what, desc = '')
529
541
  msg = "Attach popup :#{how}=>'#{what}'. #{desc}"
530
542
  popup = attach_browser(browser, how, what, desc)
@@ -541,10 +553,12 @@ No positive validations are reported but failure is rescued and reported.
541
553
  failed_to_log("Unable to attach popup :#{how}=>'#{what}'. #{desc} '#{$!}' (#{__LINE__})")
542
554
  end
543
555
 
556
+ # :category: Navigation
544
557
  def attach_popup_by_title(browser, strg, desc = '')
545
558
  attach_popup(browser, :title, strg, desc)
546
559
  end
547
560
 
561
+ # :category: Navigation
548
562
  def attach_popup_by_url(browser, pattern, desc = '')
549
563
  attach_popup(browser, :url, pattern, desc)
550
564
  end
@@ -574,6 +588,7 @@ No positive validations are reported but failure is rescued and reported.
574
588
  clear_checkbox(browser, :id, strg, value, desc)
575
589
  end
576
590
 
591
+ # :category: Bullet-Proofing
577
592
  def find_other_browsers
578
593
  cnt = 0
579
594
  if @targetBrowser.abbrev == 'IE'
@@ -590,6 +605,7 @@ No positive validations are reported but failure is rescued and reported.
590
605
  return 0
591
606
  end
592
607
 
608
+ # :category: Debug
593
609
  def get_trace(lnbr)
594
610
  callertrace = "\nCaller trace: (#{lnbr})\n"
595
611
  Kernel.caller.each_index do |x|
@@ -600,6 +616,7 @@ No positive validations are reported but failure is rescued and reported.
600
616
 
601
617
  alias dump_caller get_trace
602
618
 
619
+ # :category: Helpers
603
620
  def translate_var_list(key)
604
621
  if @var[key] and @var[key].length > 0
605
622
  list = @var[key].dup
@@ -612,6 +629,7 @@ No positive validations are reported but failure is rescued and reported.
612
629
  failed_to_log("#{__method__}: '#{$!}'")
613
630
  end
614
631
 
632
+ # :category: Helpers
615
633
  def get_variables(file, login = :role, dbg = true)
616
634
  debug_to_log("#{__method__}: file = #{file}")
617
635
  debug_to_log("#{__method__}: role = #{login}")
@@ -706,6 +724,7 @@ No positive validations are reported but failure is rescued and reported.
706
724
  fatal_to_log("#{__method__}: '#{$!}'")
707
725
  end
708
726
 
727
+ # :category: Debug
709
728
  def grab_window_list(strg)
710
729
  @ai.AutoItSetOption("WinTitleMatchMode", 2)
711
730
  list = @ai.WinList(strg)
@@ -724,35 +743,39 @@ No positive validations are reported but failure is rescued and reported.
724
743
  stuff
725
744
  end
726
745
 
746
+ # :category: Debug
727
747
  def debug_call_list(msg)
728
748
  call_array = get_call_array
729
749
  debug_to_log("#{msg}\n#{dump_array(call_array)}")
730
750
  end
731
751
 
732
- # TODO ugly, gotta lose the hardcoding...
733
- def decode_options(strg)
734
- idx = 0
735
- @options = Hash.new
736
- strg.each_char do |c|
737
- idx = idx + 1
738
- case idx
739
- when 1
740
- @options['load'] = c.to_i
741
- when 2
742
- @options['screenshot'] = c.to_i
743
- if c.to_i > 0
744
- @screenCaptureOn = true
745
- end
746
- when 3
747
- @options['hiderun'] = c.to_i
748
- # when 4
749
- # @options['another'] = c.to_i
750
- end
751
-
752
- end
753
- # puts @options.to_yaml
754
- end
752
+ #--
753
+ ## TODO ugly, gotta lose the hardcoding...
754
+ #def decode_options(strg)
755
+ # idx = 0
756
+ # @options = Hash.new
757
+ # strg.each_char do |c|
758
+ # idx = idx + 1
759
+ # case idx
760
+ # when 1
761
+ # @options['load'] = c.to_i
762
+ # when 2
763
+ # @options['screenshot'] = c.to_i
764
+ # if c.to_i > 0
765
+ # @screenCaptureOn = true
766
+ # end
767
+ # when 3
768
+ # @options['hiderun'] = c.to_i
769
+ # # when 4
770
+ # # @options['another'] = c.to_i
771
+ # end
772
+ #
773
+ # end
774
+ # # puts @options.to_yaml
775
+ #end
776
+ #++
755
777
 
778
+ # :category: User Input
756
779
  def click_popup_button(title, button, waitTime= 9, user_input=nil)
757
780
  #TODO: is winclicker still viable/available?
758
781
  wc = WinClicker.new
@@ -780,6 +803,7 @@ No positive validations are reported but failure is rescued and reported.
780
803
  # end
781
804
  end
782
805
 
806
+ # :category: Locate Elements
783
807
  def get_select_list(browser, how, what, desc = '')
784
808
  list = browser.select_list(how, what)
785
809
  if validate(browser, @myName, __LINE__)
@@ -790,6 +814,7 @@ No positive validations are reported but failure is rescued and reported.
790
814
  failed_to_log("Unable to return select list #{how}='#{what}': '#{$!}' (#{__LINE__})")
791
815
  end
792
816
 
817
+ # :category: Page Data
793
818
  def get_select_options(browser, how, what, dump = false)
794
819
  list = browser.select_list(how, what)
795
820
  dump_select_list_options(list) if dump
@@ -798,14 +823,17 @@ No positive validations are reported but failure is rescued and reported.
798
823
  failed_to_log("Unable to get select options for #{how}=>#{what}. '#{$!}'")
799
824
  end
800
825
 
826
+ # :category: Page Data
801
827
  def get_select_options_by_id(browser, strg, dump = false)
802
828
  get_select_options(browser, :id, strg, dump)
803
829
  end
804
830
 
831
+ # :category: Page Data
805
832
  def get_select_options_by_name(browser, strg, dump = false)
806
833
  get_select_options(browser, :name, strg, dump)
807
834
  end
808
835
 
836
+ # :category: Page Data
809
837
  def get_selected_options(browser, how, what)
810
838
  begin
811
839
  list = browser.select_list(how, what)
@@ -817,22 +845,26 @@ No positive validations are reported but failure is rescued and reported.
817
845
  list.selected_options
818
846
  end
819
847
 
848
+ # :category: Page Data
820
849
  def get_selected_options_by_id(browser, strg)
821
850
  get_selected_options(browser, :id, strg)
822
851
  end
823
852
 
824
853
  alias get_selected_option_by_id get_selected_options_by_id
825
854
 
855
+ # :category: Page Data
826
856
  def get_selected_options_by_name(browser, strg)
827
857
  get_selected_options(browser, :name, strg)
828
858
  end
829
859
 
830
860
  alias get_selected_option_by_name get_selected_options_by_name
831
861
 
862
+ # :category: Helpers
832
863
  def sec2hms(s)
833
864
  Time.at(s.to_i).gmtime.strftime('%H:%M:%S')
834
865
  end
835
866
 
867
+ # :category: User Input
836
868
  def select(browser, how, what, which, value, desc = '')
837
869
  msg = "Select option #{which}='#{value}' from list #{how}=#{what}. #{desc}"
838
870
  list = browser.select_list(how, what)
@@ -855,6 +887,7 @@ No positive validations are reported but failure is rescued and reported.
855
887
  failed_to_log("#Unable to #{msg}': '#{$!}'")
856
888
  end
857
889
 
890
+ # :category: User Input
858
891
  def select_option_from_list(list, what, what_strg, desc = '')
859
892
  ok = true
860
893
  msg = "#{__method__.to_s.titleize} "
@@ -884,6 +917,7 @@ No positive validations are reported but failure is rescued and reported.
884
917
  failed_to_log("#{__method__.to_s.titleize}: #{what}='#{what_strg}' could not be selected: '#{$!}'. #{desc} (#{__LINE__})")
885
918
  end
886
919
 
920
+ # :category: User Input
887
921
  def select_option_by_id_and_option_text(browser, strg, option, nofail=false, desc = '')
888
922
  msg = "Select list id=#{strg} option text='#{option}' selected."
889
923
  msg << " #{desc}" if desc.length > 0
@@ -903,6 +937,7 @@ No positive validations are reported but failure is rescued and reported.
903
937
  alias select_option_by_id select_option_by_id_and_option_text
904
938
  alias select_option_by_id_and_text select_option_by_id_and_option_text
905
939
 
940
+ # :category: User Input
906
941
  def select_option_by_name_and_option_text(browser, strg, option, desc = '')
907
942
  msg = "Select list name=#{strg} option text='#{option}' selected."
908
943
  msg << " #{desc}" if desc.length > 0
@@ -930,6 +965,7 @@ No positive validations are reported but failure is rescued and reported.
930
965
 
931
966
  alias select_option_by_name select_option_by_name_and_option_text
932
967
 
968
+ # :category: User Input
933
969
  def select_option_by_title_and_option_text(browser, strg, option, desc = '')
934
970
  msg = "Select list name=#{strg} option text='#{option}' selected."
935
971
  msg << " #{desc}" if desc.length > 0
@@ -941,6 +977,7 @@ No positive validations are reported but failure is rescued and reported.
941
977
  failed_to_log("#{msg} '#{$!}'")
942
978
  end
943
979
 
980
+ # :category: User Input
944
981
  def select_option_by_class_and_option_text(browser, strg, option, desc = '')
945
982
  msg = "Select list class=#{strg} option text='#{option}' selected."
946
983
  msg << " #{desc}" if desc.length > 0
@@ -953,6 +990,7 @@ No positive validations are reported but failure is rescued and reported.
953
990
  failed_to_log("#{msg} '#{$!}'")
954
991
  end
955
992
 
993
+ # :category: User Input
956
994
  def select_option_by_name_and_option_value(browser, strg, option, desc = '')
957
995
  msg = "Select list name=#{strg} option value='#{option}' selected."
958
996
  msg << " #{desc}" if desc.length > 0
@@ -978,6 +1016,7 @@ No positive validations are reported but failure is rescued and reported.
978
1016
  failed_to_log("#{msg} '#{$!}'")
979
1017
  end
980
1018
 
1019
+ # :category: User Input
981
1020
  def select_option_by_id_and_option_value(browser, strg, option, desc = '')
982
1021
  msg = "Select list name=#{strg} option value='#{option}' selected."
983
1022
  msg << " #{desc}" if desc.length > 0
@@ -1044,6 +1083,7 @@ No positive validations are reported but failure is rescued and reported.
1044
1083
  failed_to_log("#{msg} '#{$!}'")
1045
1084
  end
1046
1085
 
1086
+ # :category: User Input
1047
1087
  def set(browser, element, how, what, value = nil, desc = '')
1048
1088
  msg = "Set #{element} #{how}=>'#{what}' "
1049
1089
  msg << "('#{value.to_s}')" if value
@@ -1064,30 +1104,37 @@ No positive validations are reported but failure is rescued and reported.
1064
1104
  failed_to_log("#{msg} '#{$!}'")
1065
1105
  end
1066
1106
 
1107
+ # :category: User Input
1067
1108
  def set_checkbox(browser, how, what, desc = '')
1068
1109
  set(browser, :checkbox, how, what, nil, desc)
1069
1110
  end
1070
1111
 
1112
+ # :category: User Input
1071
1113
  def set_checkbox_by_class(browser, strg, value = nil, desc = '')
1072
1114
  set(browser, :checkbox, :class, strg, value, desc)
1073
1115
  end
1074
1116
 
1117
+ # :category: User Input
1075
1118
  def set_checkbox_by_id(browser, strg, value = nil, desc = '')
1076
1119
  set(browser, :checkbox, :id, strg, value, desc)
1077
1120
  end
1078
1121
 
1122
+ # :category: User Input
1079
1123
  def set_checkbox_by_name(browser, strg, value = nil, desc = '')
1080
1124
  set(browser, :checkbox, :name, strg, value, desc)
1081
1125
  end
1082
1126
 
1127
+ # :category: User Input
1083
1128
  def set_checkbox_by_title(browser, strg, value = nil, desc = '')
1084
1129
  set(browser, :checkbox, :title, strg, value, desc)
1085
1130
  end
1086
1131
 
1132
+ # :category: User Input
1087
1133
  def set_checkbox_by_value(browser, strg, desc = '')
1088
1134
  set(browser, :checkbox, :value, strg, nil, desc)
1089
1135
  end
1090
1136
 
1137
+ # :category: User Input
1091
1138
  def set_radio(browser, how, what, value = nil, desc = '')
1092
1139
  if how == :value
1093
1140
  set_radio_by_value(browser, what, desc)
@@ -1098,6 +1145,7 @@ No positive validations are reported but failure is rescued and reported.
1098
1145
  failed_to_log("#{msg} '#{$!}'")
1099
1146
  end
1100
1147
 
1148
+ # :category: User Input
1101
1149
  def set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '')
1102
1150
  msg = "Set radio #{how1}='#{what1}', #{how2}= #{what2}"
1103
1151
  msg << " '#{desc}' " if desc.length > 0
@@ -1110,26 +1158,32 @@ No positive validations are reported but failure is rescued and reported.
1110
1158
  failed_to_log("#{msg} '#{$!}'")
1111
1159
  end
1112
1160
 
1161
+ # :category: User Input
1113
1162
  def set_radio_by_class(browser, strg, value = nil, desc = '')
1114
1163
  set(browser, :radio, :class, strg, value, desc)
1115
1164
  end
1116
1165
 
1166
+ # :category: User Input
1117
1167
  def set_radio_by_id(browser, strg, value = nil, desc = '')
1118
1168
  set(browser, :radio, :id, strg, value, desc)
1119
1169
  end
1120
1170
 
1171
+ # :category: User Input
1121
1172
  def set_radio_by_index(browser, index, desc = '')
1122
1173
  set(browser, :radio, :index, index, nil, desc)
1123
1174
  end
1124
1175
 
1176
+ # :category: User Input
1125
1177
  def set_radio_by_name(browser, strg, value = nil, desc = '')
1126
1178
  set(browser, :radio, :name, strg, value, desc)
1127
1179
  end
1128
1180
 
1181
+ # :category: User Input
1129
1182
  def set_radio_by_title(browser, strg, value = nil, desc = '')
1130
1183
  set(browser, :radio, :title, strg, value, desc)
1131
1184
  end
1132
1185
 
1186
+ # :category: User Input
1133
1187
  def set_radio_no_wait_by_index(browser, index, desc = '')
1134
1188
  #TODO: Not supported by Watir 1.8.x
1135
1189
  msg = "Radio :index=#{index} "
@@ -1370,8 +1424,8 @@ No positive validations are reported but failure is rescued and reported.
1370
1424
  end
1371
1425
 
1372
1426
  =begin rdoc
1373
- category: Logon
1374
- tags: logon, login, user, password, url
1427
+ :category: Basic
1428
+ :tags:logon, login, user, password, url
1375
1429
  TODO: Needs to be more flexible about finding login id and password textfields
1376
1430
  TODO: Parameterize url and remove references to environment
1377
1431
  =end
@@ -1400,7 +1454,7 @@ TODO: Parameterize url and remove references to environment
1400
1454
 
1401
1455
  =begin rdoc
1402
1456
  category: Logon
1403
- tags: logon, login, user, password, url, basic authorization
1457
+ :tags:logon, login, user, password, url, basic authorization
1404
1458
  =end
1405
1459
  def basic_auth(browser, user, pswd, url, bypass_validate = false)
1406
1460
  mark_testlevel("Basic Authorization Login", 0)
@@ -1834,7 +1888,8 @@ tags: logon, login, user, password, url, basic authorization
1834
1888
 
1835
1889
  # howLong is integer, whatFor is a browser object
1836
1890
  =begin rdoc
1837
- tags: wait
1891
+ :category: Waits
1892
+ :tags:wait
1838
1893
  howLong is the number of seconds, text is a string to be found, threshold is the number of seconds
1839
1894
  after which a fail message is generated even though the text was detected within the howLong limit.
1840
1895
  Use this in place of wait_until_by_text when the wait time needs to be longer than the test automation default.
@@ -1952,9 +2007,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
1952
2007
 
1953
2008
  #method for handling save dialog
1954
2009
  #use click_no_wait on the action that triggers the save dialog
2010
+ def save_file(filepath, download_title = "File Download - Security Warning")
1955
2011
  # TODO need version for Firefox
1956
2012
  # TODO need to handle first character underline, e.g. 'Cancel' and '&Cancel'
1957
- def save_file(filepath, download_title = "File Download - Security Warning")
1958
2013
  download_title = translate_popup_title(download_title)
1959
2014
  download_text = ''
1960
2015
  download_control = "&Save"
@@ -2213,14 +2268,6 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2213
2268
  countdown
2214
2269
  end
2215
2270
 
2216
- #Sample usage:
2217
- # if wait_for( 10, browser.link(:id, "wria-messagebox-yes") )
2218
- # browser.link(:id, "wria-messagebox-yes").click
2219
- # . .
2220
- # else
2221
- # @myLog.error('['+__LINE__.to_s+'] '+role+' Validate Expected Confirm Delete messagebox')
2222
- # end
2223
-
2224
2271
  def wait_the_hard_way(browser, how, what, wait = 6, intvl = 0.25)
2225
2272
  count = (wait / intvl).to_i + 1
2226
2273
  tally = 0
@@ -2345,10 +2392,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2345
2392
  browser = Watir::Browser.new(:chrome)
2346
2393
  end
2347
2394
 
2348
- #=begin
2349
- # Get the browser to navigate to a given url. If not supplied in the second argument,
2350
- # defaults to value of FullScript.myURL, which is populated from ApplicationEnvironment.url.
2351
- #=end
2395
+ #Get the browser to navigate to a given url. If not supplied in the second argument,
2396
+ #defaults to value of FullScript.myURL, which is populated from ApplicationEnvironment.url.
2397
+
2352
2398
  def go_to_url(browser, url = nil, redirect = nil)
2353
2399
  if url
2354
2400
  @myURL = url
@@ -2371,7 +2417,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2371
2417
  fatal_to_log("Unable to navigate to '#{@myURL}': '#{$!}'")
2372
2418
  end
2373
2419
 
2374
- #def open_log
2420
+
2421
+ #--
2422
+ ##def open_log
2375
2423
  # start = Time.now.to_f.to_s
2376
2424
  #
2377
2425
  # logTS = Time.at(@myRun.launched.to_f).strftime("%Y%m%d%H%M%S")
@@ -2391,7 +2439,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2391
2439
  # mark_testlevel(@myChild.name, @myChild.level) # SubModule
2392
2440
  #
2393
2441
  #end
2442
+ #++
2394
2443
 
2444
+ # :category: User Input
2395
2445
  def click(browser, element, how, what, desc = '')
2396
2446
  #debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
2397
2447
  msg = "Click #{element} :#{how}=>'#{what}'"
@@ -2434,6 +2484,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2434
2484
  failed_to_log("Unable to #{msg}. '#{$!}'")
2435
2485
  end
2436
2486
 
2487
+ # :category: User Input
2437
2488
  def click_no_wait(browser, element, how, what, desc = '')
2438
2489
  debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
2439
2490
  msg = "Click no wait #{element} :#{how}=>'#{what}'"
@@ -2479,66 +2530,67 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2479
2530
  sleep_for(1)
2480
2531
  end
2481
2532
 
2533
+ # :category: User Input
2482
2534
  def click_button_by_id(browser, strg, desc = '')
2483
2535
  click(browser, :button, :id, strg, desc)
2484
2536
  end
2485
-
2537
+ # :category: User Input
2486
2538
  def click_link_by_index(browser, strg, desc = '')
2487
2539
  click(browser, :link, :index, strg, desc)
2488
2540
  end
2489
-
2541
+ # :category: User Input
2490
2542
  def click_link_by_href(browser, strg, desc = '')
2491
2543
  click(browser, :link, :href, strg, desc)
2492
2544
  end
2493
2545
 
2494
2546
  alias click_href click_link_by_href
2495
-
2547
+ # :category: User Input
2496
2548
  def click_link_no_wait_by_href(browser, strg, desc = '')
2497
2549
  click_no_wait(browser, :link, :href, strg, desc)
2498
2550
  end
2499
2551
 
2500
2552
  alias click_href_no_wait click_link_no_wait_by_href
2501
-
2553
+ # :category: User Input
2502
2554
  def click_button_by_index(browser, index, desc = '')
2503
2555
  click(browser, :button, :index, index, desc)
2504
2556
  end
2505
-
2557
+ # :category: User Input
2506
2558
  def click_button_by_name(browser, strg, desc = '')
2507
2559
  click(browser, :button, :name, strg, desc)
2508
2560
  end
2509
-
2561
+ # :category: User Input
2510
2562
  def click_button_by_text(browser, strg, desc = '')
2511
2563
  click(browser, :button, :text, strg, desc)
2512
2564
  end
2513
-
2565
+ # :category: User Input
2514
2566
  def click_button_by_class(browser, strg, desc = '')
2515
2567
  click(browser, :button, :class, strg, desc)
2516
2568
  end
2517
-
2569
+ # :category: User Input
2518
2570
  def click_button_no_wait_by_id(browser, strg, desc = '')
2519
2571
  click_no_wait(browser, :button, :id, strg, desc)
2520
2572
  end
2521
2573
 
2522
2574
  alias click_button_by_id_no_wait click_button_no_wait_by_id
2523
-
2575
+ # :category: User Input
2524
2576
  def click_button_no_wait_by_name(browser, strg, desc = '')
2525
2577
  click_no_wait(browser, :button, :name, strg, desc)
2526
2578
  end
2527
-
2579
+ # :category: User Input
2528
2580
  def click_button_no_wait_by_class(browser, strg, desc = '')
2529
2581
  click_no_wait(browser, :button, :class, strg, desc)
2530
2582
  end
2531
2583
 
2532
2584
  alias click_button_by_class_no_wait click_button_no_wait_by_class
2533
-
2585
+ # :category: User Input
2534
2586
  def click_button_by_value(browser, strg, desc = '')
2535
2587
  click(browser, :button, :value, strg, desc)
2536
2588
  end
2537
-
2589
+ # :category: User Input
2538
2590
  def click_button_by_title(browser, strg, desc = '')
2539
2591
  click(browser, :button, :title, strg, desc)
2540
2592
  end
2541
-
2593
+ # :category: User Input
2542
2594
  def click_button_by_xpath_and_id(browser, strg, desc = '')
2543
2595
  msg = "Click button by xpath and id '#{strg}' #{desc}"
2544
2596
  if browser.button(:xpath, "//a[@id = '#{strg}']").click
@@ -2552,19 +2604,19 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2552
2604
  end
2553
2605
 
2554
2606
  alias click_button_by_xpath click_button_by_xpath_and_id
2555
-
2607
+ # :category: User Input
2556
2608
  def click_link_by_id(browser, strg, desc = '')
2557
2609
  click(browser, :link, :id, strg, desc)
2558
2610
  end
2559
2611
 
2560
2612
  alias click_id click_link_by_id
2561
-
2613
+ # :category: User Input
2562
2614
  def click_link_by_name(browser, strg, desc = '')
2563
2615
  click(browser, :link, :name, strg, desc)
2564
2616
  end
2565
2617
 
2566
2618
  alias click_name click_link_by_name
2567
-
2619
+ # :category: User Input
2568
2620
  def click_link_by_xpath_and_id(browser, strg, desc = '')
2569
2621
  msg = "Click link by xpath and id '#{strg}' #{desc}"
2570
2622
  if browser.link(:xpath, "//a[@id = '#{strg}']").click
@@ -2578,7 +2630,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2578
2630
  end
2579
2631
 
2580
2632
  alias click_link_by_xpath click_link_by_xpath_and_id
2581
-
2633
+ # :category: User Input
2582
2634
  def click_link_no_wait_by_id(browser, strg, desc = '')
2583
2635
  click_no_wait(browser, :link, :id, strg, desc)
2584
2636
  end
@@ -2587,19 +2639,19 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2587
2639
  alias click_no_wait_by_id click_link_no_wait_by_id
2588
2640
  alias click_id_no_wait click_link_no_wait_by_id
2589
2641
  alias click_no_wait_link_by_id click_link_no_wait_by_id
2590
-
2642
+ # :category: User Input
2591
2643
  def click_file_field_by_id(browser, strg, desc = '')
2592
2644
  click(browser, :file_field, :id, strg, desc)
2593
2645
  end
2594
-
2646
+ # :category: User Input
2595
2647
  def click_img_by_alt(browser, strg, desc = '')
2596
2648
  click(browser, :image, :alt, strg, desc)
2597
2649
  end
2598
-
2650
+ # :category: User Input
2599
2651
  def click_img_by_title(browser, strg, desc = '')
2600
2652
  click(browser, :image, :title, strg, desc)
2601
2653
  end
2602
-
2654
+ # :category: User Input
2603
2655
  def click_img_by_xpath_and_name(browser, strg, desc = '')
2604
2656
  msg = "Click image by xpath where name='#{strg}' #{desc}"
2605
2657
  if browser.link(:xpath, "//input[@name = '#{strg}']").click
@@ -2615,17 +2667,17 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2615
2667
  alias click_img_by_xpath click_img_by_xpath_and_name
2616
2668
  alias click_image_by_xpath click_img_by_xpath_and_name
2617
2669
  alias click_image_by_xpath_and_name click_img_by_xpath_and_name
2618
-
2670
+ # :category: User Input
2619
2671
  def click_img_no_wait_by_alt(browser, strg, desc = '')
2620
2672
  click_no_wait(browser, :image, :alt, strg, desc)
2621
2673
  end
2622
2674
 
2623
2675
  alias click_img_by_alt_no_wait click_img_no_wait_by_alt
2624
-
2676
+ # :category: User Input
2625
2677
  def click_img_by_src(browser, strg, desc = '')
2626
2678
  click(browser, :image, :src, strg, desc)
2627
2679
  end
2628
-
2680
+ # :category: User Input
2629
2681
  def click_img_by_src_and_index(browser, strg, index, desc = '')
2630
2682
  msg = "Click image by src='#{strg}' and index=#{index}"
2631
2683
  msg << " #{desc}" if desc.length > 0
@@ -2637,11 +2689,11 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2637
2689
  rescue
2638
2690
  failed_to_log("Unable to #{msg} '#{$!}'")
2639
2691
  end
2640
-
2692
+ # :category: User Input
2641
2693
  def click_link_by_value(browser, strg, desc = '')
2642
2694
  click(browser, :link, :value, strg, desc)
2643
2695
  end
2644
-
2696
+ # :category: User Input
2645
2697
  def click_link_by_text(browser, strg, desc = '')
2646
2698
  click(browser, :link, :text, strg, desc)
2647
2699
  end
@@ -2649,35 +2701,35 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2649
2701
  alias click_link click_link_by_text
2650
2702
  alias click_text click_link_by_text
2651
2703
  alias click_js_button click_link_by_text
2652
-
2704
+ # :category: User Input
2653
2705
  def click_link_by_class(browser, strg, desc = '')
2654
2706
  click(browser, :link, :class, strg, desc)
2655
2707
  end
2656
2708
 
2657
2709
  alias click_class click_link_by_class
2658
-
2710
+ # :category: User Input
2659
2711
  def click_button_no_wait_by_text(browser, strg, desc = '')
2660
2712
  click_no_wait(browser, :button, :text, strg, desc)
2661
2713
  end
2662
-
2714
+ # :category: User Input
2663
2715
  def click_button_no_wait_by_value(browser, strg, desc = '')
2664
2716
  click_no_wait(browser, :button, :value, strg, desc)
2665
2717
  end
2666
-
2718
+ # :category: User Input
2667
2719
  def click_link_by_name_no_wait(browser, strg, desc = '')
2668
2720
  click_no_wait(browser, :link, :name, strg, desc)
2669
2721
  end
2670
2722
 
2671
2723
  alias click_no_wait_name click_link_by_name_no_wait
2672
2724
  alias click_name_no_wait click_link_by_name_no_wait
2673
-
2725
+ # :category: User Input
2674
2726
  def click_link_by_text_no_wait(browser, strg, desc = '')
2675
2727
  click_no_wait(browser, :link, :text, strg, desc)
2676
2728
  end
2677
2729
 
2678
2730
  alias click_no_wait_text click_link_by_text_no_wait
2679
2731
  alias click_text_no_wait click_link_by_text_no_wait
2680
-
2732
+ # :category: User Input
2681
2733
  def click_span_by_text(browser, strg, desc = '')
2682
2734
  if not desc and not strg.match(/Save|Open|Close|Submit|Cancel/)
2683
2735
  desc = 'to navigate to selection'
@@ -2691,7 +2743,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2691
2743
  failed_to_log("Unable to #{msg}: '#{$!}'")
2692
2744
  end
2693
2745
 
2694
- # TODO no logging yet. slow.
2746
+ # TODO no logging yet. slow.# :category: User Input
2695
2747
  def click_span_with_text(browser, trgt, desc = '')
2696
2748
  msg = "Find and click span containing text '#{trgt}'."
2697
2749
  msg << " #{desc}" if desc.length > 0
@@ -2709,17 +2761,17 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2709
2761
  end
2710
2762
  spans[x].click
2711
2763
  end
2712
-
2764
+ # :category: User Input
2713
2765
  def click_link_by_title(browser, strg, desc = '')
2714
2766
  click(browser, :link, :title, strg, desc)
2715
2767
  end
2716
2768
 
2717
2769
  alias click_title click_link_by_title
2718
-
2770
+ # :category: User Input
2719
2771
  def click_title_no_wait(browser, strg, desc = '')
2720
2772
  click_no_wait(browser, :link, :title, strg, desc)
2721
2773
  end
2722
-
2774
+ # :category: User Input
2723
2775
  def click_table_row_with_text_by_id(browser, ptrn, strg, column = nil)
2724
2776
  msg = "id=#{ptrn} row with text='#{strg}"
2725
2777
  table = get_table_by_id(browser, /#{ptrn}/)
@@ -2740,7 +2792,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
2740
2792
  rescue
2741
2793
  failed_to_log("Unable to click table #{msg}: '#{$!}' (#{__LINE__}) ")
2742
2794
  end
2743
-
2795
+ # :category: User Input
2744
2796
  def click_table_row_with_text_by_index(browser, idx, strg, column = nil)
2745
2797
  msg = "index=#{idx} row with text='#{strg}"
2746
2798
  table = get_table_by_index(browser, idx)
@@ -3082,6 +3134,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3082
3134
  count
3083
3135
  end
3084
3136
 
3137
+ # :category: Helpers
3085
3138
  def translate_popup_title(title)
3086
3139
  new_title = title
3087
3140
  case @browserAbbrev
@@ -3147,6 +3200,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3147
3200
  new_title
3148
3201
  end
3149
3202
 
3203
+ #--
3150
3204
  #def translate_popup_title(title)
3151
3205
  # new_title = title
3152
3206
  # case @browserAbbrev
@@ -3185,6 +3239,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3185
3239
  # end
3186
3240
  # new_title
3187
3241
  #end
3242
+ #++
3188
3243
 
3189
3244
  def get_browser_version(browser)
3190
3245
  debug_to_log("starting get_browser_version")
@@ -3315,6 +3370,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3315
3370
  alias fire_event_src fire_event_on_image_by_src
3316
3371
  alias fire_event_image_by_src fire_event_on_image_by_src
3317
3372
 
3373
+ # :category: Waits
3318
3374
  def wait_until_exists(browser, element, how, what, desc = '')
3319
3375
  msg = "Wait until (#{element} :#{how}=>#{what}) exists."
3320
3376
  msg << " #{desc}" if desc.length > 0
@@ -3367,8 +3423,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3367
3423
  failed_to_log("Unable to complete #{msg}: '#{$!}'")
3368
3424
  end
3369
3425
 
3370
- #TODO: Would like to be able to see the block code in the log message instead of the identification
3426
+ # :category: Waits
3371
3427
  def wait_while(browser, desc, timeout = 45, &block)
3428
+ #TODO: Would like to be able to see the block code in the log message instead of the identification
3372
3429
  msg = "Wait while #{desc}:"
3373
3430
  start = Time.now.to_f
3374
3431
  begin
@@ -3397,8 +3454,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3397
3454
 
3398
3455
  alias wait_while_true wait_while
3399
3456
 
3400
- #TODO: Would like to be able to see the block code in the log message instead of the identification
3457
+ # :category: Waits
3401
3458
  def wait_until(browser, desc, timeout = 45, skip_pass = false, &block)
3459
+ #TODO: Would like to be able to see the block code in the log message instead of the identification
3402
3460
  msg = "Wait until #{desc}"
3403
3461
  start = Time.now.to_f
3404
3462
  begin
@@ -3424,10 +3482,12 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3424
3482
 
3425
3483
  alias wait_until_true wait_until
3426
3484
 
3485
+ # :category: Waits
3427
3486
  def wait_until_by_radio_value(browser, strg, desc = '')
3428
3487
  wait_until_exists(browser, :radio, :value, strg, desc)
3429
3488
  end
3430
3489
 
3490
+ # :category: Waits
3431
3491
  def wait_until_ready(browser, how, what, desc = '', timeout = 90, verbose = false)
3432
3492
  msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
3433
3493
  msg << " #{desc}" if desc.length > 0
@@ -3468,6 +3528,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3468
3528
  failed_to_log("Unable to #{msg}. '#{$!}'")
3469
3529
  end
3470
3530
 
3531
+ # :category: Waits
3471
3532
  def wait_until_ready_quiet(browser, how, what, desc = '', timeout = 45, quiet = true)
3472
3533
  msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
3473
3534
  msg << " #{desc}" if desc.length > 0
@@ -3495,6 +3556,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3495
3556
  failed_to_log("Unable to #{msg}. '#{$!}'")
3496
3557
  end
3497
3558
 
3559
+ # :category: Waits
3498
3560
  def wait_until_text(browser, strg, desc = '', timeout = 60)
3499
3561
  if not strg.class.to_s.match('String')
3500
3562
  raise "#{__method__} requires String for search target. #{strg.class} is not supported."
@@ -3504,11 +3566,14 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3504
3566
 
3505
3567
  alias wait_until_by_text wait_until_text
3506
3568
 
3569
+ # :category: Waits
3507
3570
  def wait_until_by_link_text(browser, strg, desc = '')
3508
3571
  wait_until_exists(browser, :link, :text, strg, desc)
3509
3572
  end
3510
3573
 
3574
+ # :category: Waits
3511
3575
  def wait_until_enabled(browser, what, how, value, desc = '')
3576
+ # TODO: This can be simplified
3512
3577
  start = Time.now.to_f
3513
3578
  begin
3514
3579
  case what
@@ -3550,6 +3615,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3550
3615
  failed_to_log("Unable to complete wait until (#{what} :#{how}=>#{value}) enabled. #{desc}: '#{$!}'")
3551
3616
  end
3552
3617
 
3618
+ # :category: Waits
3553
3619
  def wait_until_visible(browser, element, how, what, desc = '')
3554
3620
  start = Time.now.to_f
3555
3621
  Watir::Wait.until(20) { browser.element(how, what).exists? }
@@ -3592,6 +3658,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3592
3658
  failed_to_log("Unable to complete wait until (#{element} :#{how}=>#{what}) visible. #{desc}: '#{$!}'")
3593
3659
  end
3594
3660
 
3661
+ # :category: Bullet-Proofing
3595
3662
  def rescue_me(e, me = nil, what = nil, where = nil, who = nil)
3596
3663
  #TODO: these are rescues from exceptions raised in Watir/Firewatir
3597
3664
  debug_to_log("#{__method__}: Enter")
@@ -3642,10 +3709,12 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3642
3709
  ok
3643
3710
  end
3644
3711
 
3712
+ # :category: Browser
3645
3713
  def close_popup_by_button_title(popup, strg, desc = '')
3646
3714
  click(popup, :link, :title, strg, desc)
3647
3715
  end
3648
3716
 
3717
+ # :category: GUI
3649
3718
  def move_element_with_handle(browser, element, handle_id, dx, dy)
3650
3719
  # msg = "Move element "
3651
3720
  # w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
@@ -3675,8 +3744,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3675
3744
 
3676
3745
  end
3677
3746
 
3678
- #TODO enhance to accept differing percentages in each direction
3747
+ # :category: GUI
3679
3748
  def resize_element_with_handle(browser, element, target, dx, dy=nil)
3749
+ #TODO enhance to accept differing percentages in each direction
3680
3750
  msg = "Resize element "
3681
3751
  w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
3682
3752
  if dy
@@ -3760,6 +3830,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3760
3830
  sleep_for(1)
3761
3831
  end
3762
3832
 
3833
+ # :category: GUI
3763
3834
  def get_resize_handle_by_id(element, id, dbg=nil)
3764
3835
  handle = get_div_by_id(element, id, dbg)
3765
3836
  sleep_for(1)
@@ -3767,6 +3838,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3767
3838
  return handle
3768
3839
  end
3769
3840
 
3841
+ # :category: GUI
3770
3842
  def get_resize_handle_by_class(element, strg, dbg=nil)
3771
3843
  handle = get_div_by_class(element, strg, dbg)
3772
3844
  sleep_for(0.5)
@@ -3774,6 +3846,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3774
3846
  return handle
3775
3847
  end
3776
3848
 
3849
+ # :category: GUI
3777
3850
  def get_element_coordinates(browser, element, dbg=nil)
3778
3851
  bx, by, bw, bh = get_browser_coord(browser, dbg)
3779
3852
  if @browserAbbrev == 'IE'
@@ -3871,6 +3944,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3871
3944
  failed_to_log("Unable to #{msg}: '#{$!}'")
3872
3945
  end
3873
3946
 
3947
+ # :category: GUI
3874
3948
  def adjust_dimensions_by_percent(w, h, p, returnnew=nil)
3875
3949
  p += 100
3876
3950
  nw = (w * (p/100.0)).to_i
@@ -3884,6 +3958,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3884
3958
  end
3885
3959
  end
3886
3960
 
3961
+ # :category: GUI
3887
3962
  def get_browser_coord(browser=nil, dbg=nil)
3888
3963
  browser = @myBrowser if not browser
3889
3964
  title = browser.title
@@ -3899,6 +3974,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3899
3974
  [x, y, w, h]
3900
3975
  end
3901
3976
 
3977
+ # :category: Table Handling
3902
3978
  def get_index_for_column_head(panel, table_index, strg)
3903
3979
  rgx = Regexp.new(strg)
3904
3980
  panel.tables[table_index].each do |row|
@@ -3914,6 +3990,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3914
3990
  end
3915
3991
  end
3916
3992
 
3993
+ # :category: Table Handling
3917
3994
  def get_index_of_last_row(table, pad = 2, every = 1)
3918
3995
  index = calc_index(table.row_count, every)
3919
3996
  index = index.to_s.rjust(pad, '0')
@@ -3923,6 +4000,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3923
4000
 
3924
4001
  alias get_index_for_last_row get_index_of_last_row
3925
4002
 
4003
+ # :category: Table Handling
3926
4004
  def get_index_of_last_row_with_text(table, strg, column_index = nil)
3927
4005
  debug_to_log("#{__method__}: #{get_callers(5)}")
3928
4006
  msg = "Find last row in table :id=#{table.id} with text '#{strg}'"
@@ -3965,6 +4043,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
3965
4043
 
3966
4044
  alias get_index_for_last_row_with_text get_index_of_last_row_with_text
3967
4045
 
4046
+ # :category: Table Handling
3968
4047
  def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false)
3969
4048
  debug_to_log("#{__method__}: #{get_callers(5)}")
3970
4049
  if fail_if_found
@@ -4016,6 +4095,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4016
4095
  failed_to_log("Unable to #{msg}. '#{$!}'")
4017
4096
  end
4018
4097
 
4098
+ # :category: Table Handling
4019
4099
  def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
4020
4100
  msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
4021
4101
  msg << " in column #{column_index}" if column_index
@@ -4053,6 +4133,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4053
4133
  failed_to_log("Unable to #{msg}. '#{$!}'")
4054
4134
  end
4055
4135
 
4136
+ # :category: Table Handling
4056
4137
  def get_index_for_table_containing_text(browser, strg, ordinal = 1)
4057
4138
  msg = "Get index for table containing text '#{strg}'"
4058
4139
  index = 0
@@ -4091,6 +4172,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4091
4172
  failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
4092
4173
  end
4093
4174
 
4175
+ # :category: Table Handling
4094
4176
  def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
4095
4177
  rgx = Regexp.new(strg)
4096
4178
  text = ''
@@ -4113,6 +4195,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4113
4195
  text
4114
4196
  end
4115
4197
 
4198
+ # :category: Table Handling
4116
4199
  def count_rows_with_string(container, table_index, strg)
4117
4200
  hit = 0
4118
4201
  container.tables[table_index].each do |row|
@@ -4131,6 +4214,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4131
4214
  hit
4132
4215
  end
4133
4216
 
4217
+ # :category: Table Handling
4134
4218
  def fetch_array_for_table_column(nc_element, table_index, column_index)
4135
4219
  ary = []
4136
4220
  nc_element.tables[table_index].each do |row|
@@ -4144,6 +4228,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4144
4228
  return ary f
4145
4229
  end
4146
4230
 
4231
+ # :category: Table Handling
4147
4232
  def fetch_hash_for_table_column(table, column_index, start_row = 2)
4148
4233
  hash = Hash.new
4149
4234
  row_count = 0
@@ -4158,6 +4243,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4158
4243
  hash
4159
4244
  end
4160
4245
 
4246
+ # :category: Table Handling
4161
4247
  def get_row_cells_text_as_array(row)
4162
4248
  ary = []
4163
4249
  row.each do |cell|
@@ -4166,6 +4252,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4166
4252
  ary
4167
4253
  end
4168
4254
 
4255
+ # :category: Table Handling
4169
4256
  def count_data_rows(container, data_index, column_index)
4170
4257
  cnt = 0
4171
4258
  # get_objects(container, :tables, true)
@@ -4185,6 +4272,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4185
4272
  cnt
4186
4273
  end
4187
4274
 
4275
+ # :category: GUI
4188
4276
  def drag_and_drop(x1, y1, dx, dy, speed=nil)
4189
4277
  speed = 10 if not speed
4190
4278
  x2 = x1 + dx
@@ -4199,6 +4287,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4199
4287
  @ai.MouseClickDrag("primary", x1, y1, x2, y2, speed)
4200
4288
  end
4201
4289
 
4290
+ # :category: GUI
4202
4291
  def drag_and_drop_element(browser, element, dx, dy, speed = nil)
4203
4292
  speed = 10 if not speed
4204
4293
  w1, h1, x1, y1, xc1, yc1, xlr1, ylr1 = get_element_coordinates(browser, element, true)
@@ -4344,12 +4433,14 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4344
4433
  idx
4345
4434
  end
4346
4435
 
4436
+ # :category: GUI
4347
4437
  def right_click(element)
4348
4438
  x = element.left_edge_absolute + 2
4349
4439
  y = element.top_edge_absolute + 2
4350
4440
  @ai.MouseClick("secondary", x, y)
4351
4441
  end
4352
4442
 
4443
+ # :category: GUI
4353
4444
  def left_click(element)
4354
4445
  x = element.left_edge_absolute + 2
4355
4446
  y = element.top_edge_absolute + 2
@@ -4364,6 +4455,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4364
4455
  # end
4365
4456
  end
4366
4457
 
4458
+ # :category: GUI
4367
4459
  def screen_offset(element, browser=nil)
4368
4460
  bx, by, bw, bh = get_browser_coord(browser)
4369
4461
  ex = element.left_edge
@@ -4371,6 +4463,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4371
4463
  [bx + ex, by + ey]
4372
4464
  end
4373
4465
 
4466
+ # :category: GUI
4374
4467
  def screen_center(element, browser=nil)
4375
4468
  bx, by, bw, bh = get_browser_coord(browser)
4376
4469
  w, h = element.dimensions.to_a
@@ -4393,6 +4486,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4393
4486
  error_to_log("#{where.inspect} doesn't seem to respond to element() #{$!}")
4394
4487
  end
4395
4488
 
4489
+ # :category: User Input
4396
4490
  def click_me(element)
4397
4491
  element.click
4398
4492
  rescue
@@ -4407,12 +4501,14 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4407
4501
  end
4408
4502
  end
4409
4503
 
4504
+ # :category: Debug
4410
4505
  def get_caller_line
4411
4506
  last_caller = get_callers[0]
4412
4507
  line = last_caller.split(':', 3)[1]
4413
4508
  line
4414
4509
  end
4415
4510
 
4511
+ # :category: Debug
4416
4512
  def get_call_list(depth = 9, dbg = false)
4417
4513
  myList = []
4418
4514
  call_list = Kernel.caller
@@ -4428,6 +4524,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4428
4524
 
4429
4525
  alias get_callers get_call_list
4430
4526
 
4527
+ # :category: Debug
4431
4528
  def get_call_list_new(depth = 9, dbg = false)
4432
4529
  myList = []
4433
4530
  call_list = Kernel.caller
@@ -4455,6 +4552,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4455
4552
  myList
4456
4553
  end
4457
4554
 
4555
+ # :category: Debug
4458
4556
  def get_call_array(depth = 9)
4459
4557
  arr = []
4460
4558
  call_list = Kernel.caller
@@ -4467,6 +4565,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4467
4565
  arr
4468
4566
  end
4469
4567
 
4568
+ # :category: Debug
4470
4569
  def get_debug_list(dbg = false)
4471
4570
  calls = get_call_array(10)
4472
4571
  puts "#{calls.to_yaml}" if dbg
@@ -4486,6 +4585,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4486
4585
  end
4487
4586
  end
4488
4587
 
4588
+ # :category: Debug
4489
4589
  def dump_all_tables(browser, to_report = false)
4490
4590
  tables = browser.tables
4491
4591
  msg = ''
@@ -4511,6 +4611,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4511
4611
  end
4512
4612
  end
4513
4613
 
4614
+ # :category: Debug
4514
4615
  def dump_table_and_rows(table, to_report = false)
4515
4616
  msg = "\n=================\ntable\n=================\nn#{table}\n#{table.to_yaml}\nrows:"
4516
4617
  cnt = 0
@@ -4526,6 +4627,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4526
4627
  end
4527
4628
  end
4528
4629
 
4630
+ # :category: Debug
4529
4631
  def dump_table_rows_and_cells(tbl)
4530
4632
  msg = ''
4531
4633
  row_cnt = 0
@@ -4544,6 +4646,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4544
4646
 
4545
4647
  alias dump_table_rows dump_table_rows_and_cells
4546
4648
 
4649
+ # :category: Debug
4547
4650
  def dump_array(arr, space_to_underscore = false)
4548
4651
  dump = " #{arr.inspect}\n"
4549
4652
  arr.each_index do |x|
@@ -4554,6 +4657,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4554
4657
  dump
4555
4658
  end
4556
4659
 
4660
+ # :category: Debug
4557
4661
  def dump_ole_methods(ole)
4558
4662
  rtrn = ''
4559
4663
  ole.ole_methods.each do |m|
@@ -4566,6 +4670,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4566
4670
  rtrn
4567
4671
  end
4568
4672
 
4673
+ # :category: Debug
4569
4674
  def dump_ole_get_methods(ole)
4570
4675
  rtrn = ''
4571
4676
  ole.ole_get_methods.each do |m|
@@ -4578,6 +4683,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4578
4683
  rtrn
4579
4684
  end
4580
4685
 
4686
+ # :category: Debug
4581
4687
  def dump_ole_help(ole)
4582
4688
  rtrn = ''
4583
4689
  ole.ole_obj_help.each do |m|
@@ -4590,6 +4696,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4590
4696
  rtrn
4591
4697
  end
4592
4698
 
4699
+ # :category: Debug
4593
4700
  def dump_row_cells(row)
4594
4701
  msg = ''
4595
4702
  cell_cnt = 0
@@ -4601,6 +4708,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
4601
4708
  debug_to_log(msg)
4602
4709
  end
4603
4710
 
4711
+ # :category: Debug
4604
4712
  def dump_select_list_options(element)
4605
4713
  msg = "#{element.inspect}"
4606
4714
  options = element.options