awetestlib 0.0.3-x86-mingw32 → 0.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,200 +32,38 @@ module Validations
32
32
  end
33
33
  end
34
34
 
35
- =begin rdoc
36
- Verifies health of the browser. Looks for common http and system errors that are unrecoverable and
37
- attempts to gracefully bail out of the script. Calls rescue_me() when trying to capture the text to filter out
38
- known false errors and handle container elements that don't respond to the .text method.
39
- category: bullet-proofing
40
- tags: system, http, fatal, error
41
- example: See click()
42
- related methods: rescue_me()
43
- =end
44
- def validate(browser, fileName = '', lnbr = __LINE__, dbg = false)
45
- debug_to_log("#{__method__} begin") if dbg
46
- msg = ''
47
- myOK = true
48
- if not browser
49
- msg = "#{fileName}----browser is nil object. (#{lnbr})"
50
- myOK = false
51
- elsif not is_browser?(browser)
52
- msg = "#{fileName}----not a browser. (#{lnbr})"
53
- debug_to_log(browser.inspect)
54
- myOK = false
55
-
56
- else
57
- if browser.respond_to?(:url)
58
- if not browser.url == @currentURL
59
- @currentURL = browser.url
60
- debug_to_log("Current URL: [#{@currentURL}]")
61
- # mark_testlevel( "Current URL: [#{@currentURL}]", 1 )
62
- end
63
- end
64
-
65
- if @capture_js_errors
66
- if browser.respond_to?(:status)
67
- if browser.status.downcase =~ /errors? on page/ and
68
- not browser.status.downcase.include?('Waiting for')
69
- capture_js_error(browser)
70
- end
71
- end
72
- end
73
-
74
- begin
75
- browser_text = browser.text.downcase
76
- rescue => e
77
- if not rescue_me(e, __method__, "browser.text.downcase", "#{browser.class}", browser)
78
- debug_to_log("browser.text.downcase in #{__method__} #{browser.class}")
79
- debug_to_log("#{get_callers}")
80
- raise e
81
- else
82
- return true
83
- end
84
- end
85
-
86
- if browser_text
87
- if browser_text.match(/unrecognized error condition has occurred/i)
88
- msg = "#{fileName}----Unrecognized Exception occurred. (#{lnbr})"
89
- myOK = false
90
-
91
- elsif browser_text.match(/cannot find server or dns error/i)
92
- msg = "#{fileName}----Cannot find server error or DNS error. (#{lnbr})"
93
- myOK = false
94
-
95
- elsif browser_text.match(/the rpc server is unavailable/i)
96
- msg = "#{fileName}----RPC server unavailable. (#{lnbr})"
97
- myOK = false
98
-
99
- elsif browser_text.match(/404 not found/i) or
100
- browser_text.match(/the page you were looking for does\s*n[o']t exist/i)
101
- msg = "#{fileName}----RFC 2068 HTTP/1.1: 404 URI Not Found. (#{lnbr})"
102
- myOK = false
103
-
104
- elsif browser_text.match(/we're sorry, but something went wrong/i) or
105
- browser_text.match(/http status 500/i)
106
- msg = "#{fileName}----RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
107
- myOK = false
108
-
109
- elsif browser_text.match(/internet explorer cannot display the webpage/i)
110
- msg = "#{fileName}----Probably RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
111
- myOK = false
112
-
113
- elsif browser_text.match(/503.*service unavailable/i)
114
- msg = "#{fileName}----RFC 2068 HTTP/1.1: 503 Service Unavailable. (#{lnbr})"
115
- myOK = false
116
-
117
- elsif browser_text.match(/java.lang.NullPointerException/i)
118
- msg = "#{fileName}----java.lang.NullPointerException. (#{lnbr})"
119
- myOK = false
120
-
121
- elsif browser_text.match(/due to unscheduled maintenance/i)
122
- msg = "#{fileName}----Due to unscheduled maintenance. (#{lnbr})"
123
- myOK = false
124
-
125
- elsif browser_text.match(/network\s+error\s*(.+)$/i)
126
- $1.chomp!
127
- msg = "#{fileName}----Network Error #{$1}. (#{lnbr})"
128
- myOK = false
129
-
130
- elsif browser_text.match(/warning: page has expired/i)
131
- msg = "#{fileName}----Page using information from form has expired. Not automatically resubmitted. (#{lnbr})"
132
- myOK = false
133
-
134
- elsif browser_text.match(/no backend server available/i)
135
- msg = "#{fileName}----Cannot Reach Server (#{lnbr})"
136
- myOK = false
137
-
138
- elsif browser_text.match(/sign on\s+.+\s+unsuccessful/i)
139
- msg = "#{fileName}----Invalid Id or Password (#{lnbr})"
140
- myOK = false
141
-
142
- elsif browser_text.match(/you are not authorized/i)
143
- msg = "#{fileName}----Not authorized to view this page. (#{lnbr})"
144
- myOK = false
145
-
146
- elsif browser_text.match(/too many incorrect login attempts have been made/i)
147
- msg = "#{fileName}----Invalid Id or Password. Too many tries. (#{lnbr})"
148
- myOK = false
149
-
150
- elsif browser_text.match(/system error\.\s+an error has occurred/i)
151
- msg = "#{fileName}----System Error. An error has occurred. Please try again or call the Help Line for assistance. (#{lnbr})"
152
- myOK = false
153
-
154
- elsif browser_text.match(/Internal Server failure,\s+NSAPI plugin/i)
155
- msg = "#{fileName}----Internal Server failure, NSAPI plugin. (#{lnbr})"
156
- myOK = false
157
-
158
- elsif browser_text.match(/Error Page/i)
159
- msg = "#{fileName}----Error Page. (#{lnbr})"
160
- myOK = false
161
-
162
- elsif browser_text.match(/The website cannot display the page/i)
163
- msg = "#{fileName}----HTTP 500. (#{lnbr})"
164
- myOK = false
165
-
166
- # elsif browser_text.match(/Insufficient Data/i)
167
- # msg = "#{fileName}----Insufficient Data. (#{lnbr})"
168
- # myOK = false
169
-
170
- elsif browser_text.match(/The timeout period elapsed/i)
171
- msg = "#{fileName}----Time out period elapsed or server not responding. (#{lnbr})"
172
- myOK = false
173
-
174
- elsif browser_text.match(/Unexpected\s+errors*\s+occur+ed\.\s+(?:-+)\s+(.+)/i)
175
- msg = "#{fileName}----Unexpected errors occurred. #{$2.slice(0, 120)} (#{lnbr})"
176
- if not browser_text.match(/close the window and try again/i)
177
- myOK = false
178
- else
179
- debug_to_log("#{msg}")
180
- end
181
-
182
- elsif browser_text.match(/Server Error in (.+) Application\.\s+(?:-+)\s+(.+)/i)
183
- msg = "#{fileName}----Server Error in #{1} Application. #{$2.slice(0, 100)} (#{lnbr})"
184
- myOK = false
185
-
186
- elsif browser_text.match(/Server Error in (.+) Application\./i)
187
- msg = "#{fileName}----Server Error in #{1} Application. '#{browser_text.slice(0, 250)}...' (#{lnbr})"
188
- myOK = false
189
-
190
- elsif browser_text.match(/An error has occur+ed\. Please contact support/i)
191
- msg = "#{fileName}----An error has occurred. Please contact support (#{lnbr})"
192
- myOK = false
193
-
194
- end
195
- else
196
- debug_to_log("browser.text returned nil")
197
- end
35
+ def validate_message(browser, message)
36
+ if validate(browser, @myName, __LINE__)
37
+ message_to_log(message)
198
38
  end
39
+ end
199
40
 
200
- if not myOK
201
- msg << " (#{browser.url})"
202
- puts msg
203
- debug_to_log(browser.inspect)
204
- debug_to_log(browser.text)
205
- fatal_to_log(msg, lnbr)
206
- raise(RuntimeError, msg, caller)
41
+ def validate_style_value(browser, element, how, what, type, expected, desc = '')
42
+ #TODO: works only with watir-webdriver
43
+ msg = "Expected CSS style #{type} value '#{expected}' in #{element} with #{how} = #{what}"
44
+ msg << " #{desc}" if desc.length > 0
45
+ case element
46
+ when :link
47
+ actual = browser.link(how => what).style type
48
+ when :button
49
+ actual = browser.button(how => what).style type
50
+ when :image
51
+ actual = browser.image(how => what).style type
52
+ when :span
53
+ actual = browser.span(how => what).style type
54
+ when :div
55
+ actual = browser.div(how => what).style type
56
+ end
57
+ if expected == actual
58
+ passed_to_log(msg)
207
59
  else
208
- debug_to_log("#{__method__} returning OK") if dbg
209
- return myOK
60
+ failed_to_log(msg)
210
61
  end
211
-
212
62
  rescue
213
- errmsg = $!
214
- if errmsg.match(msg)
215
- errmsg = ''
216
- end
217
- bail_out(browser, lnbr, "#{msg} #{errmsg}")
63
+ failed_to_log( "Unable to validate #{msg} '#{$!}'")
218
64
  end
219
65
 
220
- alias validate_browser validate
221
-
222
- def validate_message(browser, message)
223
- if validate(browser, @myName, __LINE__)
224
- message_to_log(message)
225
- end
226
- end
227
-
228
- ##### begin core validation methods #####
66
+ ##### begin core validation methods #####
229
67
 
230
68
  def arrays_match?(exp, act, dir, col, org = nil)
231
69
  if exp == act
@@ -242,7 +80,8 @@ related methods: rescue_me()
242
80
  alias arrays_match arrays_match?
243
81
 
244
82
  def enabled?(browser, element, how, what, desc = '')
245
- msg = "#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled. #{desc}"
83
+ msg = "#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled.}"
84
+ msg << " #{desc}" if desc.length > 0
246
85
  case element
247
86
  when :textfield, :textarea, :text_area, :text_field
248
87
  rtrn = browser.text_field(how, what).enabled? and not browser.text_field(how, what).readonly?
@@ -320,6 +159,7 @@ related methods: rescue_me()
320
159
  alias validate_disabled disabled?
321
160
 
322
161
  def verify_text_in_table_with_text(table, text, value)
162
+ #TODO This needs clarification, renaming
323
163
  msg = "Table :id=>#{table.id} with text '#{text} contains '#{value}."
324
164
  index = get_index_of_row_with_text(table, text)
325
165
  if table[index].text =~ value
@@ -400,6 +240,24 @@ related methods: rescue_me()
400
240
  alias checkbox_checked? checked?
401
241
  alias checkbox_set? checked?
402
242
 
243
+ def not_checked?(browser, how, what, desc = '')
244
+ msg = "Checkbox #{how}=>#{what} is not checked."
245
+ msg << " #{desc}" if desc.length > 0
246
+ if not browser.checkbox(how, what).checked?
247
+ if validate(browser, @myName, __LINE__)
248
+ passed_to_log(msg)
249
+ true
250
+ end
251
+ else
252
+ failed_to_log(msg)
253
+ end
254
+ rescue
255
+ failed_to_log("Unable to validate #{msg}: '#{$!}'")
256
+ end
257
+
258
+ alias checkbox_checked? checked?
259
+ alias checkbox_set? checked?
260
+
403
261
  def exists?(browser, element, how, what, value = nil, desc = '')
404
262
  msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
405
263
  msg << "and value=>'#{value}' " if value
@@ -433,6 +291,7 @@ related methods: rescue_me()
433
291
  alias not_exist? does_not_exist?
434
292
 
435
293
  def set?(browser, how, what, desc = '', no_fail = false)
294
+ #TODO Needs to handle radio value as well
436
295
  msg = "Radio #{how}=>#{what} is selected."
437
296
  msg << " #{desc}" if desc.length > 0
438
297
  if browser.radio(how, what).set?
@@ -455,25 +314,90 @@ related methods: rescue_me()
455
314
  alias radio_checked? set?
456
315
  alias radio_selected? set?
457
316
 
458
- def select_list_includes?(browser, how, what, option)
317
+ def not_set?(browser, how, what, desc = '', no_fail = false)
318
+ #TODO Needs to handle radio value as well
319
+ msg = "Radio #{how}=>#{what} is not selectedd."
320
+ msg << " #{desc}" if desc.length > 0
321
+ if not browser.radio(how, what).set?
322
+ if validate(browser, @myName, __LINE__)
323
+ passed_to_log(msg)
324
+ true
325
+ end
326
+ else
327
+ if no_fail
328
+ passed_to_log("Radio #{how}=>#{what} is not selected.")
329
+ else
330
+ failed_to_log(msg)
331
+ end
332
+ end
333
+ rescue
334
+ failed_to_log("Unable to validate #{msg}: '#{$!}'")
335
+ end
336
+
337
+ alias radio_not_set? not_set?
338
+ alias radio_not_checked? not_set?
339
+ alias radio_not_selected? not_set?
340
+
341
+ def radio_with_value_set?(browser, how, what, value, desc = '', no_fail = false)
342
+ msg = "Radio #{how}=>#{what} :value=>#{value} is selected."
343
+ msg << " #{desc}" if desc.length > 0
344
+ if browser.radio(how, what, value).set?
345
+ if validate(browser, @myName, __LINE__)
346
+ passed_to_log(msg)
347
+ true
348
+ end
349
+ else
350
+ if no_fail
351
+ passed_to_log("Radio #{how}=>#{what} :value=>#{value} is not selected.")
352
+ else
353
+ failed_to_log(msg)
354
+ end
355
+ end
356
+ rescue
357
+ failed_to_log("Unable to validate #{msg}: '#{$!}'")
358
+ end
359
+
360
+ alias radio_set_with_value? radio_with_value_set?
361
+
362
+ def select_list_includes?(browser, how, what, option, desc = '')
363
+ msg = "Select list #{how}=>#{what} includes option '#{option}'."
364
+ msg << " #{desc}" if desc.length > 0
459
365
  select_list = browser.select_list(how, what)
460
366
  options = select_list.options
461
367
  if option
462
368
  if options.include?(option)
463
- passed_to_log("Select list options contain option '#{option}'.")
369
+ passed_to_log(msg)
464
370
  true
465
371
  else
466
- failed_to_log("Select list options #{options} do not contain option '#{option}'.")
372
+ failed_to_log(msg)
467
373
  nil
468
374
  end
469
375
  end
470
376
  rescue
471
- failed_to_log("Unable to verify select_list contains option '#{option}': '#{$!}'", __LINE__)
377
+ failed_to_log("Unable to verify #{msg}. '#{$!}'")
472
378
  end
473
379
 
474
380
  alias validate_select_list_contains select_list_includes?
475
381
  alias select_list_contains? select_list_includes?
476
382
 
383
+ def select_list_does_not_include?(browser, how, what, option, desc = '')
384
+ msg = "Select list #{how}=>#{what} does not include option '#{option}'."
385
+ msg << " #{desc}" if desc.length > 0
386
+ select_list = browser.select_list(how, what)
387
+ options = select_list.options
388
+ if option
389
+ if not options.include?(option)
390
+ passed_to_log(msg)
391
+ true
392
+ else
393
+ failed_to_log(msg)
394
+ nil
395
+ end
396
+ end
397
+ rescue
398
+ failed_to_log("Unable to verify #{msg}. '#{$!}'")
399
+ end
400
+
477
401
  def string_equals?(actual, target, desc = '')
478
402
  msg = "Assert actual '#{actual}' equals expected '#{target}'. #{desc} "
479
403
  if actual == target
@@ -491,6 +415,20 @@ related methods: rescue_me()
491
415
  alias text_equals string_equals?
492
416
  alias text_equals? string_equals?
493
417
 
418
+ def string_does_not_equal?(strg, target, desc = '')
419
+ msg = "String '#{strg}' does not equal '#{target}'."
420
+ msg << " '#{desc}' " if desc.length > 0
421
+ if strg == target
422
+ failed_to_log("#{msg} (#{__LINE__})")
423
+ true
424
+ else
425
+ passed_to_log("#{msg} (#{__LINE__})")
426
+ end
427
+ end
428
+
429
+ alias validate_string_not_equal string_does_not_equal?
430
+ alias validate_string_does_not_equal string_does_not_equal?
431
+
494
432
  def read_only?(browser, element, how, what, value = nil, desc = '')
495
433
  msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
496
434
  msg << "and value=>'#{value}' " if value
@@ -592,9 +530,8 @@ related methods: rescue_me()
592
530
  ##### end backward compatible methods #####
593
531
 
594
532
 
595
- # TODO Deprecated: all util1 methods should be catching
596
- # this issue
597
533
  def link_enabled?(browser, strg)
534
+ #TODO Use enabled?()
598
535
  count = string_count_in_string(browser.text, strg)
599
536
  if count > 0
600
537
  if browser.link(:text, strg).enabled?
@@ -615,9 +552,8 @@ related methods: rescue_me()
615
552
 
616
553
  alias validate_link_enabled link_enabled?
617
554
 
618
- # TODO Deprecated: all util1 methods should be catching
619
- # this issue
620
555
  def link_disabled?(browser, strg)
556
+ #TODO use disabled?()
621
557
  count = string_count_in_string(browser.text, strg)
622
558
  if count > 0
623
559
  if browser.link(:text, strg).enabled?
@@ -678,6 +614,7 @@ related methods: rescue_me()
678
614
 
679
615
  #Validate select list contains text
680
616
  def validate_list_by_id(browser, strg, text, message, select_if_present=true)
617
+ #TODO Use select_list_includes?() ?
681
618
  if browser.select_list(:id, strg).exists?
682
619
  select_list = browser.select_list(:id, strg)
683
620
  if select_list.include?(text)
@@ -708,6 +645,7 @@ related methods: rescue_me()
708
645
 
709
646
  #Validate select list contains text
710
647
  def validate_list_by_name(browser, strg, text, message, select_if_present=true)
648
+ #TODO Use select_list_includes?() ?
711
649
  if browser.select_list(:name, strg).exists?
712
650
  select_list = browser.select_list(:name, strg)
713
651
  if select_list.include?(text)
@@ -737,34 +675,10 @@ related methods: rescue_me()
737
675
  end
738
676
 
739
677
  #Validate select list does not contain text
740
- def validate_no_list(browser, id, text, message)
741
- if browser.select_list(:id, id).includes?(text)
742
- if validate(browser, @myName, __LINE__)
743
- failed_to_log(message + " (#{__LINE__})")
744
- end
745
- else
746
- passed_to_log(message + " (#{__LINE__})")
747
- true
748
- end
749
- rescue
750
- failed_to_log("Unable to validate that '#{text}' did not in select list with name='#{listName}: '#{$!}'. (#{__LINE__})")
678
+ def validate_no_list(browser, id, text, desc = '')
679
+ select_list_does_not_include?(browser, :id, id, text, desc)
751
680
  end
752
681
 
753
- def validate_resize(d, err, tol, min, act)
754
- ary = [false, "failed, actual #{act} err #{err}"]
755
- if err == 0
756
- ary = [true, 'succeeded ']
757
- #TODO need to find way to calculate this adjustment
758
- elsif d <= min + 4
759
- ary = [true, "reached minimum (#{min}) "]
760
- elsif err.abs <= tol
761
- ary = [true, "within tolerance (+-#{tol}px) "]
762
- end
763
- ary
764
- end
765
-
766
- alias validate_move validate_resize
767
-
768
682
  def validate_text(browser, ptrn, desc = '', skip_fail = false, skip_sleep = false)
769
683
  cls = browser.class.to_s
770
684
  cls.gsub!('Watir::', '')
@@ -806,7 +720,7 @@ related methods: rescue_me()
806
720
  msg = "Expected exact text '#{expected}' in #{element} :#{how}=>#{what}."
807
721
  msg << " #{desc}" if desc.length > 0
808
722
  text = ''
809
- who = browser.element(how, what)
723
+ who = browser.element(how, what)
810
724
  if who
811
725
  text = who.text
812
726
  if text == expected
@@ -827,7 +741,7 @@ related methods: rescue_me()
827
741
  end
828
742
 
829
743
  def element_contains_text?(browser, element, how, what, expected, desc = '')
830
- msg = "Expected #{element} :{how}=>#{what} to contain text '#{expected}'."
744
+ msg = "Element #{element} :{how}=>#{what} contains text '#{expected}'."
831
745
  msg << " #{desc}" if desc.length > 0
832
746
  who = browser.element(how, what)
833
747
  if who
@@ -929,7 +843,6 @@ related methods: rescue_me()
929
843
  failed_to_log("Unable to validate select_list: '#{$!}'", __LINE__)
930
844
  end
931
845
 
932
-
933
846
  def validate_select_list_contents(browser, how, what, list)
934
847
  mark_testlevel("#{__method__.to_s.titleize} (#{what})", 2)
935
848
  select_list = browser.select_list(how, what)
@@ -981,8 +894,9 @@ related methods: rescue_me()
981
894
  alias validate_selections validate_selected_options
982
895
  alias validate_select_list_selections validate_selected_options
983
896
 
984
- def validate_string_contains(strg, target, desc = '')
985
- msg = "Assert '#{strg}' contains '#{target}'? #{desc} "
897
+ def string_contains?(strg, target, desc = '')
898
+ msg = "String '#{strg}' contains '#{target}'."
899
+ msg << " '#{desc}' " if desc.length > 0
986
900
  if strg.match(target)
987
901
  passed_to_log("#{msg} (#{__LINE__})")
988
902
  true
@@ -991,10 +905,12 @@ related methods: rescue_me()
991
905
  end
992
906
  end
993
907
 
994
- alias validate_string validate_string_contains
908
+ alias validate_string string_contains?
909
+ alias validate_string_contains string_contains?
995
910
 
996
- def validate_string_does_not_contain(strg, target, message = '')
997
- msg = "Assert '#{strg}' does not contain '#{target}'? #{message} "
911
+ def string_does_not_contain?(strg, target, desc = '')
912
+ msg = "String '#{strg}' does not contain '#{target}'."
913
+ msg << " '#{desc}' " if desc.length > 0
998
914
  if strg.match(target)
999
915
  failed_to_log("#{msg} (#{__LINE__})")
1000
916
  true
@@ -1003,20 +919,9 @@ related methods: rescue_me()
1003
919
  end
1004
920
  end
1005
921
 
1006
- alias validate_string_not_contains validate_string_does_not_contain
1007
- alias validate_string_not_contain validate_string_does_not_contain
1008
-
1009
- def validate_string_does_not_equal(strg, target, message = '')
1010
- msg = "Assert '#{strg}' does not equal '#{target}'? #{message} "
1011
- if strg == target
1012
- failed_to_log("#{msg} (#{__LINE__})")
1013
- true
1014
- else
1015
- passed_to_log("#{msg} (#{__LINE__})")
1016
- end
1017
- end
1018
-
1019
- alias validate_string_not_equal validate_string_does_not_equal
922
+ alias validate_string_not_contains string_does_not_contain?
923
+ alias validate_string_not_contain string_does_not_contain?
924
+ alias validate_string_does_not_contain string_does_not_contain?
1020
925
 
1021
926
  def validate_no_text(browser, ptrn, desc = '')
1022
927
  cls = browser.class.to_s
@@ -1042,10 +947,10 @@ related methods: rescue_me()
1042
947
  failed_to_log("Unable to validate #{msg}: '#{$!}'")
1043
948
  end
1044
949
 
1045
- def validate_textfield_not_value(browser, how, what, value, desc = '')
1046
- msg = "Text field #{how}=>#{what} does not contain '#{value}'"
950
+ def textfield_does_not_equal?(browser, how, what, expected, desc = '')
951
+ msg = "Text field #{how}=>#{what} does not equal '#{expected}'"
1047
952
  msg << " #{desc}" if desc.length > 0
1048
- if not browser.text_field(how, what).value == value
953
+ if not browser.text_field(how, what).value == expected
1049
954
  if validate(browser, @myName, __LINE__)
1050
955
  passed_to_log(msg)
1051
956
  true
@@ -1057,21 +962,23 @@ related methods: rescue_me()
1057
962
  failed_to_log("Unable to validate that #{msg}: '#{$!}'")
1058
963
  end
1059
964
 
965
+ alias validate_textfield_not_value textfield_does_not_equal?
966
+
1060
967
  ###################################
1061
968
  def validate_textfield_not_value_by_name(browser, name, value, desc = '')
1062
- validate_textfield_not_value(browser, :name, name, value, desc)
969
+ textfield_does_not_equal?(browser, :name, name, value, desc)
1063
970
  end
1064
971
 
1065
972
  alias validate_textfield_no_value_by_name validate_textfield_not_value_by_name
1066
973
 
1067
974
  ###################################
1068
975
  def validate_textfield_not_value_by_id(browser, id, value, desc = '')
1069
- validate_textfield_not_value(browser, :id, id, value, desc)
976
+ textfield_does_not_equal?(browser, :id, id, value, desc)
1070
977
  end
1071
978
 
1072
979
  alias validate_textfield_no_value_by_id validate_textfield_not_value_by_id
1073
980
 
1074
- def validate_textfield_empty(browser, how, what, desc = '')
981
+ def textfield_empty?(browser, how, what, desc = '')
1075
982
  msg = "Text field #{how}=>#{what} is empty."
1076
983
  msg << desc if desc.length > 0
1077
984
  value = browser.text_field(how, what).value
@@ -1087,6 +994,9 @@ related methods: rescue_me()
1087
994
  failed_to_log("Unable to validate #{msg} '#{$!}'")
1088
995
  end
1089
996
 
997
+ alias validate_textfield_empty textfield_empty?
998
+ alias text_field_empty? textfield_empty?
999
+
1090
1000
  def validate_textfield_empty_by_name(browser, name, message = '')
1091
1001
  validate_textfield_empty(browser, :name, name, message)
1092
1002
  end
@@ -1099,7 +1009,7 @@ related methods: rescue_me()
1099
1009
  validate_textfield_empty(browser, :title, title, message)
1100
1010
  end
1101
1011
 
1102
- def validate_textfield_value(browser, how, what, expected, desc = '')
1012
+ def textfield_equals?(browser, how, what, expected, desc = '')
1103
1013
  msg = "Expected '#{expected}' in textfield #{how}=>'#{what}'. #{desc}"
1104
1014
  actual = browser.text_field(how, what).value
1105
1015
  if actual.is_a?(Array)
@@ -1133,6 +1043,9 @@ related methods: rescue_me()
1133
1043
  failed_to_log("Unable to validate #{msg}: '#{$!}")
1134
1044
  end
1135
1045
 
1046
+ alias validate_textfield_value textfield_equals?
1047
+ alias text_field_equals? textfield_equals?
1048
+
1136
1049
  def validate_textfield_dollar_value(browser, how, what, expected, with_cents = true, desc = '')
1137
1050
  desc << " Dollar formatting"
1138
1051
  if with_cents
@@ -1142,69 +1055,37 @@ related methods: rescue_me()
1142
1055
  expected.gsub!(/\.00$/, '')
1143
1056
  desc << ' with cents.'
1144
1057
  end
1145
- validate_textfield_value(browser, how, what, expected, desc)
1058
+ textfield_equals?(browser, how, what, expected, desc)
1146
1059
  end
1147
1060
 
1148
1061
  def validate_textfield_value_by_name(browser, name, expected, desc = '')
1149
- validate_textfield_value(browser, :name, name, expected, desc)
1062
+ textfield_equals?(browser, :name, name, expected, desc)
1150
1063
  end
1151
1064
 
1152
1065
  def validate_textfield_value_by_id(browser, id, expected, desc = '')
1153
- validate_textfield_value(browser, :id, id, expected, desc)
1066
+ textfield_equals?(browser, :id, id, expected, desc)
1154
1067
  end
1155
1068
 
1156
1069
  def validate_textfield_visible_by_name(browser, strg, desc = '')
1157
- sleep_for(1)
1158
- if browser.text_field(:name, strg).visible?
1159
- passed_to_log("Textfield with :name='#{strg}' is visible as expected. #{desc}")
1160
- true
1161
- else
1162
- failed_to_log("Textfield with :name='#{strg}' is not visible. #{desc}")
1163
- end
1164
- rescue
1165
- failed_to_log("Unable to validate textfield with :name=>'#{strg}' is visible. #{desc}: '#{$!}'. (#{__LINE__})")
1070
+ visible?(browser, :text_field, :name, strg, desc)
1166
1071
  end
1167
1072
 
1168
1073
  alias visible_textfield_by_name validate_textfield_visible_by_name
1169
1074
 
1170
1075
  def validate_textfield_disabled_by_name(browser, strg, desc = '')
1171
- sleep_for(1)
1172
- if browser.text_field(:name, strg).disabled?
1173
- passed_to_log("Textfield with :name='#{strg}' is disabled as expected. #{desc}")
1174
- true
1175
- else
1176
- failed_to_log("Textfield with :name='#{strg}' is not disabled. #{desc}")
1177
- end
1178
- rescue
1179
- failed_to_log("Unable to validate textfield with :name=>'#{strg}' is disabled. #{desc}: '#{$!}'. (#{__LINE__})")
1076
+ disabled?(browser, :text_field, :name, strg, desc)
1180
1077
  end
1181
1078
 
1182
1079
  alias disabled_textfield_by_name validate_textfield_disabled_by_name
1183
1080
 
1184
1081
  def validate_textfield_enabled_by_name(browser, strg, desc = '')
1185
- sleep_for(1)
1186
- if browser.text_field(:name, strg).enabled?
1187
- passed_to_log("Textfield with :name='#{strg}' is enabled as expected. #{desc}")
1188
- true
1189
- else
1190
- failed_to_log("Textfield with :name='#{strg}' is not enabled. #{desc}")
1191
- end
1192
- rescue
1193
- failed_to_log("Unable to validate textfield with :name=>'#{strg}' is enabled. #{desc}: '#{$!}'. (#{__LINE__})")
1082
+ enabled?(browser, :text_field, :name, strg, desc)
1194
1083
  end
1195
1084
 
1196
1085
  alias enabled_textfield_by_name validate_textfield_enabled_by_name
1197
1086
 
1198
1087
  def validate_textfield_not_visible_by_name(browser, strg, desc = '')
1199
- sleep_for(1)
1200
- if browser.text_field(:name, strg).visible?
1201
- failed_to_log("Textfield with :name='#{strg}' is visible. #{desc}")
1202
- true
1203
- else
1204
- passed_to_log("Textfield with :name='#{strg}' is not visible as expected. #{desc}")
1205
- end
1206
- rescue
1207
- failed_to_log("Unable to validate textfield with :name=>'#{strg}' is not visible. #{desc}: '#{$!}'. (#{__LINE__})")
1088
+ not_visible?(browser, :text_field, :name, strg, desc)
1208
1089
  end
1209
1090
 
1210
1091
  alias visible_no_textfield_by_name validate_textfield_not_visible_by_name
@@ -1260,56 +1141,24 @@ related methods: rescue_me()
1260
1141
  alias validate_check checked_by_id?
1261
1142
  alias checkbox_is_checked? checked_by_id?
1262
1143
 
1263
- def checkbox_is_enabled?(browser, strg, message)
1264
- if browser.checkbox(:id, strg).enabled?
1265
- passed_to_log(message, __LINE__)
1266
- true
1267
- else
1268
- failed_to_log("Not Enabled. (#{__LINE__})")
1269
- end
1270
- rescue
1271
- failed_to_log("Unable to validate check box with id=#{strg}: '#{$!}'. (#{__LINE__})")
1144
+ def checkbox_is_enabled?(browser, strg, desc = '')
1145
+ enabled?(browser, :checkbox, :id, strg, desc)
1272
1146
  end
1273
1147
 
1274
1148
  alias validate_check_enabled checkbox_is_enabled?
1275
1149
 
1276
- def checkbox_is_disabled?(browser, strg, message)
1277
- if browser.checkbox(:id, strg).disabled?
1278
- passed_to_log(message, __LINE__)
1279
- true
1280
- else
1281
- failed_to_log("Not Disabled. (#{__LINE__})")
1282
- end
1283
- rescue
1284
- failed_to_log("Unable to validate check box with id=#{strg}: '#{$!}'. (#{__LINE__})")
1150
+ def checkbox_is_disabled?(browser, strg, desc = '')
1151
+ disabled?(browser, :checkbox, :id, strg, desc)
1285
1152
  end
1286
1153
 
1287
1154
  alias validate_check_disabled checkbox_is_disabled?
1288
1155
 
1289
- def validate_check_by_class(browser, strg, message)
1290
- if browser.radio(:class, strg).checked?
1291
- if validate(browser, @myName, __LINE__)
1292
- passed_to_log(message)
1293
- true
1294
- end
1295
- else
1296
- failed_to_log(message + " (#{__LINE__})")
1297
- end
1298
- rescue
1299
- failed_to_log("Unable to validate check box with id=#{strg}: '#{$!}'. (#{__LINE__})")
1156
+ def validate_check_by_class(browser, strg, desc)
1157
+ checked?(browser, :class, strg, desc)
1300
1158
  end
1301
1159
 
1302
- def checkbox_not_checked?(browser, strg, message)
1303
- if browser.radio(:id, strg).checked?
1304
- if validate(browser, @myName, __LINE__)
1305
- failed_to_log(message + " (#{__LINE__})")
1306
- end
1307
- else
1308
- passed_to_log(message)
1309
- true
1310
- end
1311
- rescue
1312
- failed_to_log("Unable to validate radio with id=#{strg}: '#{$!}'. (#{__LINE__})")
1160
+ def checkbox_not_checked?(browser, strg, desc)
1161
+ not_checked?(browser, :id, strg, desc)
1313
1162
  end
1314
1163
 
1315
1164
  alias validate_not_check checkbox_not_checked?
@@ -1327,182 +1176,4 @@ related methods: rescue_me()
1327
1176
  failed_to_log("Unable to validate that '#{+source}' image appeared in page: '#{$!}'. (#{__LINE__})")
1328
1177
  end
1329
1178
 
1330
- #TODO unstub
1331
- def verify_column_hidden(browser, panel, table_index, column_name)
1332
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
1333
- return true
1334
- # id = @column_data_display_ids[column_name]
1335
- # ok = false
1336
-
1337
- # row = panel.tables[2][3]
1338
-
1339
- # row.each do |cell|
1340
- ## strg = cell.to_s
1341
- ## insp = cell.inspect
1342
- ## ole = cell.ole_object
1343
- ## anId = cell.attribute_value(:id)
1344
- # text = cell.text
1345
- # if text =~ /#{id}/
1346
- # if cell.to_s =~ /hidden/
1347
- # passed_to_log( "Column '#{column_name}' is hidden.")
1348
- # else
1349
- # failed_to_log( "Column '#{column_name}' is not hidden.")
1350
- # end
1351
- # ok = true
1352
- # end
1353
- # end
1354
- # if not ok
1355
- # failed_to_log( "Column '#{column_name}' not found.")
1356
- # end
1357
- # rescue
1358
- # failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
1359
- end
1360
-
1361
- #TODO unstub
1362
- def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
1363
- passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
1364
- return true
1365
-
1366
- row = browser.tables[data_index][row_index]
1367
- # debug_to_log( "#{row.to_a}")
1368
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
1369
- act_ary = get_row_cells_text_as_array(row)
1370
-
1371
- if not act_ary.include?(column_name)
1372
- passed_to_log("Column '#{column_name}' is hidden.")
1373
- else
1374
- failed_to_log("Column '#{column_name}' is not hidden.")
1375
- end
1376
- end
1377
-
1378
- #TODO unstub
1379
- def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
1380
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
1381
- return true
1382
-
1383
- row = browser.tables[data_index][row_index]
1384
- #TODO cells are all still there in the row. Need to check for clue to hidden/visible in other tag attributes
1385
- act_ary = get_row_cells_text_as_array(row)
1386
-
1387
- if act_ary.include?(column_name)
1388
- passed_to_log("Column '#{column_name}' is visible.")
1389
- else
1390
- failed_to_log("Column '#{column_name}' is not visible.")
1391
- end
1392
- end
1393
-
1394
- #TODO unstub
1395
- def verify_column_visible(browser, panel, table_index, column_name)
1396
-
1397
- passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
1398
- return true
1399
-
1400
- # id = @column_data_display_ids[column_name]
1401
- # ok = false
1402
- # row = panel.tables[table_index][1]
1403
- # row.each do |cell|
1404
- # if cell.id == id
1405
- # if not cell.to_s =~ /hidden/
1406
- # passed_to_log("Column '#{column_name}' is visible.")
1407
- # else
1408
- # failed_to_log("Column '#{column_name}' is not visible.")
1409
- # end
1410
- # ok = true
1411
- # end
1412
- # end
1413
- # if not ok
1414
- # failed_to_log("Column '#{column_name}' not found.")
1415
- # end
1416
- rescue
1417
- failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
1418
- end
1419
-
1420
- def verify_column_order(browser, table_index, row_index, exp_ary)
1421
- mark_testlevel("Verify Column Order", 2)
1422
- row = browser.tables[table_index][row_index]
1423
- act_ary = get_row_cells_text_as_array(row)
1424
-
1425
- if exp_ary == act_ary
1426
- passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
1427
- else
1428
- failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
1429
- end
1430
- sleep_for(1)
1431
- end
1432
-
1433
- def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
1434
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
1435
- if not column_index
1436
- column_index = get_index_for_column_head(nc_element, table_index, strg)
1437
- end
1438
-
1439
- if column_index
1440
- bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
1441
- if strg =~ /date/i
1442
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
1443
- else
1444
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
1445
- end
1446
-
1447
- if click_text(browser, strg)
1448
- if column_index
1449
- sleep_for(2.5)
1450
- else
1451
- sleep_for(1)
1452
- end
1453
- act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
1454
-
1455
- if exp_ary == act_ary
1456
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
1457
- true
1458
- else
1459
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
1460
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
1461
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
1462
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
1463
- end
1464
- end
1465
- else
1466
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
1467
- end
1468
- rescue
1469
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
1470
- end
1471
-
1472
- def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
1473
- mark_testlevel("Verify Column Sort '#{strg}'", 3)
1474
-
1475
- if not column_index
1476
- column_index = get_index_for_column_head(browser, table_index, strg)
1477
- end
1478
-
1479
- if column_index
1480
- bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
1481
- if strg =~ /date/i
1482
- exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
1483
- else
1484
- exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
1485
- end
1486
-
1487
- if click_text(browser, strg)
1488
- sleep_for(3)
1489
- act_ary = fetch_array_for_table_column(browser, table_index, column_index)
1490
-
1491
- if exp_ary == act_ary
1492
- passed_to_log("Click on column '#{strg}' produces expected sorted list.")
1493
- true
1494
- else
1495
- failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
1496
- debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
1497
- debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
1498
- debug_to_log(" Actual order ['#{act_ary.join("', '")}']")
1499
- end
1500
- end
1501
- else
1502
- failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
1503
- end
1504
- rescue
1505
- failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
1506
- end
1507
-
1508
1179
  end