awetestlib 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +7 -0
- data/lib/awetestlib.rb +3 -1
- data/lib/awetestlib/html_report.rb +15 -44
- data/lib/awetestlib/logging.rb +334 -374
- data/lib/awetestlib/regression/browser.rb +61 -71
- data/lib/awetestlib/regression/drag_and_drop.rb +31 -5
- data/lib/awetestlib/regression/find.rb +21 -139
- data/lib/awetestlib/regression/legacy.rb +1175 -1
- data/lib/awetestlib/regression/runner.rb +10 -6
- data/lib/awetestlib/regression/tables.rb +71 -25
- data/lib/awetestlib/regression/user_input.rb +88 -900
- data/lib/awetestlib/regression/utilities.rb +43 -18
- data/lib/awetestlib/regression/validations.rb +165 -248
- data/lib/awetestlib/regression/waits.rb +180 -94
- data/lib/awetestlib/runner.rb +1 -0
- data/lib/version.rb +2 -2
- data/test/create_zoho_account1.rb +1 -1
- data/test/login.xls +0 -0
- data/test/login_1.rb +37 -0
- data/test/login_1a.rb +37 -0
- data/test/login_2.rb +32 -0
- data/test/zoho_exercise.rb +21 -0
- metadata +10 -4
@@ -52,10 +52,10 @@ module Awetestlib
|
|
52
52
|
|
53
53
|
def build_message(strg1, desc = '', strg2 = '', strg3 = '', strg4 = '')
|
54
54
|
msg = "#{strg1}"
|
55
|
-
msg << " #{desc}" if desc.length > 0
|
56
|
-
msg << " #{strg2}" if strg2.length > 0
|
57
|
-
msg << " #{strg3}" if strg3.length > 0
|
58
|
-
msg << " #{strg4}" if strg4.length > 0
|
55
|
+
msg << " #{desc}" if desc and desc.length > 0
|
56
|
+
msg << " #{strg2}" if strg2 and strg2.length > 0
|
57
|
+
msg << " #{strg3}" if strg3 and strg3.length > 0
|
58
|
+
msg << " #{strg4}" if strg4 and strg4.length > 0
|
59
59
|
msg
|
60
60
|
end
|
61
61
|
|
@@ -105,9 +105,13 @@ module Awetestlib
|
|
105
105
|
(index / every) + (every - 1)
|
106
106
|
end
|
107
107
|
|
108
|
-
def get_variables(file,
|
108
|
+
def get_variables(file, key_type = :role, dbg = true)
|
109
|
+
#TODO refactor this
|
109
110
|
debug_to_log("#{__method__}: file = #{file}")
|
110
|
-
debug_to_log("#{__method__}:
|
111
|
+
debug_to_log("#{__method__}: key = #{key_type}")
|
112
|
+
|
113
|
+
script_found_in_login = false
|
114
|
+
script_found_in_data = false
|
111
115
|
|
112
116
|
@var = Hash.new
|
113
117
|
workbook = Excel.new(file)
|
@@ -119,6 +123,7 @@ module Awetestlib
|
|
119
123
|
scriptName = workbook.cell(1, col)
|
120
124
|
if scriptName == @myName
|
121
125
|
var_col = col
|
126
|
+
script_found_in_data = true
|
122
127
|
break
|
123
128
|
end
|
124
129
|
end
|
@@ -140,15 +145,16 @@ module Awetestlib
|
|
140
145
|
password_col = 0
|
141
146
|
url_col = 0
|
142
147
|
name_col = 0
|
143
|
-
|
144
|
-
if
|
145
|
-
workbook.default_sheet = workbook.sheets[
|
148
|
+
login_index = find_sheet_with_name(workbook, 'Login')
|
149
|
+
if login_index and login_index >= 0
|
150
|
+
workbook.default_sheet = workbook.sheets[login_index]
|
146
151
|
|
147
152
|
1.upto(workbook.last_column) do |col|
|
148
153
|
a_cell = workbook.cell(1, col)
|
149
154
|
case a_cell
|
150
155
|
when @myName
|
151
156
|
login_col = col
|
157
|
+
script_found_in_login = true
|
152
158
|
break
|
153
159
|
when 'role'
|
154
160
|
role_col = col
|
@@ -171,13 +177,13 @@ module Awetestlib
|
|
171
177
|
username = workbook.cell(line, name_col)
|
172
178
|
enabled = workbook.cell(line, login_col).to_s
|
173
179
|
|
174
|
-
case
|
175
|
-
when :id
|
180
|
+
case key_type
|
181
|
+
when :id, :userid
|
176
182
|
key = userid
|
177
183
|
when :role
|
178
184
|
key = role
|
179
185
|
else
|
180
|
-
key =
|
186
|
+
key = userid
|
181
187
|
end
|
182
188
|
|
183
189
|
@login[key] = Hash.new
|
@@ -191,12 +197,17 @@ module Awetestlib
|
|
191
197
|
end
|
192
198
|
|
193
199
|
@login.keys.sort.each do |key|
|
194
|
-
message_tolog("@login (by #{
|
200
|
+
message_tolog("@login (by #{key_type}): #{key}=>'#{@login[key].to_yaml}'")
|
195
201
|
end if dbg
|
196
202
|
end
|
197
203
|
|
204
|
+
if script_found_in_login and script_found_in_data
|
205
|
+
true
|
206
|
+
else
|
207
|
+
failed_to_log("Script found: in Login = #{script_found_in_login}; in Data = #{script_found_in_data}")
|
208
|
+
end
|
198
209
|
rescue
|
199
|
-
|
210
|
+
failed_to_log("#{__method__}: '#{$!}'")
|
200
211
|
end
|
201
212
|
|
202
213
|
def translate_var_list(key)
|
@@ -345,9 +356,9 @@ module Awetestlib
|
|
345
356
|
puts call_list if dbg
|
346
357
|
call_list.each_index do |x|
|
347
358
|
myCaller = call_list[x].to_s
|
348
|
-
break if x > depth or myCaller =~ /:in .run.$/
|
349
359
|
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
350
360
|
myList << "[#{$1.gsub(/eval/, @myName)}] "
|
361
|
+
break if x > depth or myCaller =~ /:in .run.$/
|
351
362
|
end
|
352
363
|
myList
|
353
364
|
end
|
@@ -360,23 +371,23 @@ module Awetestlib
|
|
360
371
|
puts call_list if dbg
|
361
372
|
call_list.each_index do |x|
|
362
373
|
myCaller = call_list[x].to_s
|
363
|
-
break if x > depth or myCaller =~ /:in .run.$/
|
364
374
|
if myCaller.include? @myName
|
365
375
|
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
366
376
|
myList << "[#{$1.gsub(/eval/, @myName)}] "
|
367
377
|
break
|
368
378
|
end
|
379
|
+
break if x > depth or myCaller =~ /:in .run.$/
|
369
380
|
end
|
370
381
|
if @projName
|
371
382
|
call_list.each_index do |x|
|
372
383
|
myCaller = call_list[x].to_s
|
373
|
-
break if x > depth or myCaller =~ /:in .run.$/
|
374
384
|
if myCaller.include? @projName
|
375
385
|
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
376
386
|
myList << "[#{$1.gsub(/eval/, @projName)}] "
|
377
387
|
break
|
378
388
|
end
|
379
389
|
end
|
390
|
+
break if x > depth or myCaller =~ /:in .run.$/
|
380
391
|
end
|
381
392
|
myList
|
382
393
|
end
|
@@ -386,9 +397,9 @@ module Awetestlib
|
|
386
397
|
call_list = Kernel.caller
|
387
398
|
call_list.each_index do |x|
|
388
399
|
myCaller = call_list[x].to_s
|
389
|
-
break if x > depth or myCaller =~ /:in .run.$/
|
390
400
|
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
391
401
|
arr << $1.gsub(/eval/, @myName)
|
402
|
+
break if x > depth or myCaller =~ /:in .run.$/
|
392
403
|
end
|
393
404
|
arr
|
394
405
|
end
|
@@ -912,6 +923,20 @@ module Awetestlib
|
|
912
923
|
error_to_log("#{$!} (#{__LINE__})")
|
913
924
|
end
|
914
925
|
|
926
|
+
def rescue_me_command(element, how, what, command = nil, param = nil, container = :browser)
|
927
|
+
loc = "#{container}.#{element}(#{how}, #{what})"
|
928
|
+
loc << ".#{command}" if command
|
929
|
+
loc << "(#{param})" if param
|
930
|
+
loc
|
931
|
+
end
|
932
|
+
|
933
|
+
def method_to_title(method, no_sub = false)
|
934
|
+
title = method.to_s.titleize
|
935
|
+
title.gsub!(/And/, '&') unless no_sub
|
936
|
+
title
|
937
|
+
rescue
|
938
|
+
debug_to_log("#{__method__}: #{method} #{$!}")
|
939
|
+
end
|
915
940
|
|
916
941
|
end
|
917
942
|
end
|
@@ -36,7 +36,7 @@ module Awetestlib
|
|
36
36
|
if browser.element(how => what).responds_to?("style")
|
37
37
|
actual = browser.element(how => what).style type
|
38
38
|
else
|
39
|
-
failed_to_log("#{msg}: Element #{element} does not
|
39
|
+
failed_to_log("#{msg}: Element #{element} does not repond to style command.")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
if expected == actual
|
@@ -49,6 +49,68 @@ module Awetestlib
|
|
49
49
|
failed_to_log("Unable to verify that #{msg} '#{$!}'")
|
50
50
|
end
|
51
51
|
|
52
|
+
def validate_style_greater_than_value(browser, element, how, what, type, value, desc = '')
|
53
|
+
case element
|
54
|
+
when :link
|
55
|
+
actual_value = browser.link(how => what).style type
|
56
|
+
when :button
|
57
|
+
actual_value = browser.button(how => what).style type
|
58
|
+
when :image
|
59
|
+
actual_value = browser.image(how => what).style type
|
60
|
+
when :span
|
61
|
+
actual_value = browser.span(how => what).style type
|
62
|
+
when :div
|
63
|
+
actual_value = browser.div(how => what).style type
|
64
|
+
else
|
65
|
+
actual_value = browser.element(how => what).style type
|
66
|
+
end
|
67
|
+
msg = build_message("The CSS value for style #{type} in #{element} :#{how}=>#{what}: '#{actual_value}' is greater than #{value}.", desc)
|
68
|
+
|
69
|
+
if actual_value.to_i > value.to_i
|
70
|
+
passed_to_log(msg)
|
71
|
+
elsif actual_value.to_i >~ value.to_i
|
72
|
+
passed_to_log(msg)
|
73
|
+
else
|
74
|
+
failed_to_log(msg)
|
75
|
+
end
|
76
|
+
rescue
|
77
|
+
fail_to_log("Unable to verify #{msg} '#{$!}'")
|
78
|
+
# sleep_for(1)
|
79
|
+
end
|
80
|
+
|
81
|
+
alias validate_style_greaterthan_value validate_style_greater_than_value
|
82
|
+
|
83
|
+
def validate_style_less_than_value(browser, element, how, what, type, value, desc = '')
|
84
|
+
case element
|
85
|
+
when :link
|
86
|
+
actual_value = browser.link(how => what).style type
|
87
|
+
when :button
|
88
|
+
actual_value = browser.button(how => what).style type
|
89
|
+
when :image
|
90
|
+
actual_value = browser.image(how => what).style type
|
91
|
+
when :span
|
92
|
+
actual_value = browser.span(how => what).style type
|
93
|
+
when :div
|
94
|
+
actual_value = browser.div(how => what).style type
|
95
|
+
else
|
96
|
+
actual_value = browser.element(how => what).style type
|
97
|
+
end
|
98
|
+
msg = build_message("The CSS value for style #{type} in #{element} :#{how}=>#{what}: '#{actual_value}' is greater than #{value}.", desc)
|
99
|
+
|
100
|
+
if actual_value.to_i < value.to_i
|
101
|
+
passed_to_log(msg)
|
102
|
+
elsif actual_value.to_i <~ value.to_i
|
103
|
+
passed_to_log(msg)
|
104
|
+
else
|
105
|
+
failed_to_log(msg)
|
106
|
+
end
|
107
|
+
rescue
|
108
|
+
fail_to_log("Unable to verify #{msg} '#{$!}'")
|
109
|
+
# sleep_for(1)
|
110
|
+
end
|
111
|
+
|
112
|
+
alias validate_style_lessthan_value validate_style_less_than_value
|
113
|
+
|
52
114
|
# @todo Clarify and rename
|
53
115
|
def arrays_match?(exp, act, dir, col, org = nil, desc = '')
|
54
116
|
if exp == act
|
@@ -248,8 +310,13 @@ module Awetestlib
|
|
248
310
|
def exists?(browser, element, how, what, value = nil, desc = '')
|
249
311
|
msg2 = "and value=>'#{value}' " if value
|
250
312
|
msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists.', desc)
|
251
|
-
|
252
|
-
|
313
|
+
case element
|
314
|
+
when :link
|
315
|
+
bool = browser.link(how, what).exists?
|
316
|
+
else
|
317
|
+
bool = browser.element(how, what).exists?
|
318
|
+
end
|
319
|
+
if bool
|
253
320
|
passed_to_log("#{msg}? #{desc}")
|
254
321
|
true
|
255
322
|
else
|
@@ -265,7 +332,13 @@ module Awetestlib
|
|
265
332
|
def does_not_exist?(browser, element, how, what, value = nil, desc = '')
|
266
333
|
msg2 = "and value=>'#{value}' " if value
|
267
334
|
msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'does not exist.', desc)
|
268
|
-
|
335
|
+
case element
|
336
|
+
when :link
|
337
|
+
bool = browser.link(how, what).exists?
|
338
|
+
else
|
339
|
+
bool = browser.element(how, what).exists?
|
340
|
+
end
|
341
|
+
if bool
|
269
342
|
failed_to_log(msg)
|
270
343
|
else
|
271
344
|
passed_to_log(msg)
|
@@ -365,7 +438,7 @@ module Awetestlib
|
|
365
438
|
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
366
439
|
# @return [Boolean] Returns true if the option is found.
|
367
440
|
def select_list_includes?(browser, how, what, option, desc = '')
|
368
|
-
msg
|
441
|
+
msg = build_message("Select list #{how}=>#{what} includes option '#{option}'.", desc)
|
369
442
|
select_list = browser.select_list(how, what)
|
370
443
|
options = select_list.options
|
371
444
|
if option
|
@@ -374,7 +447,6 @@ module Awetestlib
|
|
374
447
|
true
|
375
448
|
else
|
376
449
|
failed_to_log(msg)
|
377
|
-
nil
|
378
450
|
end
|
379
451
|
end
|
380
452
|
rescue
|
@@ -387,9 +459,9 @@ module Awetestlib
|
|
387
459
|
# Verify that a select list, identified by the value (*what*) in attribute *how*, contains an option with the
|
388
460
|
# value in *option*.
|
389
461
|
# @param (see #select_list_includes?)
|
390
|
-
|
462
|
+
# @return [Boolean] Returns true if the option is not found.
|
391
463
|
def select_list_does_not_include?(browser, how, what, option, desc = '')
|
392
|
-
msg
|
464
|
+
msg = build_message("Select list #{how}=>#{what} does not include option '#{option}'.", desc)
|
393
465
|
select_list = browser.select_list(how, what)
|
394
466
|
options = select_list.options
|
395
467
|
if option
|
@@ -412,7 +484,7 @@ module Awetestlib
|
|
412
484
|
# @return [Boolean] Returns true if actual exactly matches expected.
|
413
485
|
def string_equals?(actual, expected, desc = '')
|
414
486
|
msg = build_message("Actual string '#{actual}' equals expected '#{expected}'.", desc)
|
415
|
-
if
|
487
|
+
if actual == expected
|
416
488
|
passed_to_log("#{msg}")
|
417
489
|
true
|
418
490
|
else
|
@@ -453,12 +525,12 @@ module Awetestlib
|
|
453
525
|
if actual == expected
|
454
526
|
rtrn = true
|
455
527
|
elsif DateTime.parse(actual).to_s == DateTime.parse(expected).to_s
|
456
|
-
msg2
|
528
|
+
msg2 "with different formatting. "
|
457
529
|
unless fail_on_format
|
458
530
|
rtrn = true
|
459
531
|
end
|
460
532
|
end
|
461
|
-
msg
|
533
|
+
msg = build_message("Actual date '#{actual}' equals expected date '#{expected}'.", msg2, desc)
|
462
534
|
if rtrn
|
463
535
|
passed_to_log("#{msg}")
|
464
536
|
else
|
@@ -515,7 +587,7 @@ module Awetestlib
|
|
515
587
|
def ready?(browser, element, how, what, value = '', desc = '')
|
516
588
|
msg2 = "and value=>'#{value}' " if value
|
517
589
|
msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists and is enabled.', desc)
|
518
|
-
e
|
590
|
+
e = get_element(browser, element, how, what, value)
|
519
591
|
if e and e.enabled?
|
520
592
|
passed_to_log(msg)
|
521
593
|
true
|
@@ -526,6 +598,15 @@ module Awetestlib
|
|
526
598
|
failed_to_log("Unable to determine if #{msg}. '#{$!}' [#{get_callers(1)}]")
|
527
599
|
end
|
528
600
|
|
601
|
+
# Verify that a text field (also text area), identified by *how* and *what*, contains only the exact string specified in *expected*.
|
602
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
603
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
604
|
+
# Valid values depend on the kind of element.
|
605
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
606
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
607
|
+
# @param [String] expected A string which the value attribute of the text field must equal.
|
608
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
609
|
+
# @return [Boolean] Returns true if the *expected* and the value in the text field are identical.
|
529
610
|
def textfield_equals?(browser, how, what, expected, desc = '')
|
530
611
|
msg = build_message("Expected value to equal '#{expected}' in textfield #{how}=>'#{what}'.", desc)
|
531
612
|
actual = browser.text_field(how, what).value
|
@@ -557,10 +638,19 @@ module Awetestlib
|
|
557
638
|
alias validate_textfield_value textfield_equals?
|
558
639
|
alias text_field_equals? textfield_equals?
|
559
640
|
|
560
|
-
|
561
|
-
|
641
|
+
# Verify that a text field (also text area), identified by *how* and *what*, contains the string specified in *expected*.
|
642
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
643
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
644
|
+
# Valid values depend on the kind of element.
|
645
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
646
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
647
|
+
# @param [String, Regexp] expected A string or regular expression which must be matched in the value of the text field
|
648
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
649
|
+
# @return [Boolean] Returns true if the *expected* is matched in the value of the text field.
|
650
|
+
def textfield_contains?(browser, how, what, expected, desc = '')
|
651
|
+
msg = build_message("Text field #{how}=>#{what} contains '#{expected}'.", desc)
|
562
652
|
contents = browser.text_field(how, what).value
|
563
|
-
if contents =~ /#{
|
653
|
+
if contents =~ /#{expected}/
|
564
654
|
passed_to_log(msg)
|
565
655
|
true
|
566
656
|
else
|
@@ -570,6 +660,14 @@ module Awetestlib
|
|
570
660
|
failed_to_log("Unable to verify that #{msg} '#{$!}'")
|
571
661
|
end
|
572
662
|
|
663
|
+
# Verify that a text field (also text area), identified by *how* and *what*, is empty.
|
664
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
665
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
666
|
+
# Valid values depend on the kind of element.
|
667
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
668
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
669
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
670
|
+
# @return [Boolean] Returns true if the text field is empty.
|
573
671
|
def textfield_empty?(browser, how, what, desc = '')
|
574
672
|
msg = "Text field #{how}=>#{what} is empty."
|
575
673
|
msg << desc if desc.length > 0
|
@@ -587,27 +685,43 @@ module Awetestlib
|
|
587
685
|
alias validate_textfield_empty textfield_empty?
|
588
686
|
alias text_field_empty? textfield_empty?
|
589
687
|
|
688
|
+
# Verify that a text field (also text area), identified by *how* and *what*, contains the string specified in *expected*.
|
689
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
690
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
691
|
+
# Valid values depend on the kind of element.
|
692
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
693
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
694
|
+
# @param [String] expected A string in dollar formatting
|
695
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
696
|
+
# @return [Boolean] Returns true if the *expected* is matched in the value of the text field.
|
590
697
|
def validate_textfield_dollar_value(browser, how, what, expected, with_cents = true, desc = '')
|
698
|
+
target = expected.dup
|
591
699
|
desc << " Dollar formatting"
|
592
700
|
if with_cents
|
593
|
-
|
594
|
-
desc <<
|
701
|
+
target << '.00' if not expected =~ /\.00$/
|
702
|
+
desc << " without cents. orig:(#{expected})"
|
595
703
|
else
|
596
|
-
|
597
|
-
desc <<
|
704
|
+
target.gsub!(/\.00$/, '')
|
705
|
+
desc << " with cents. orig:(#{expected})"
|
598
706
|
end
|
599
|
-
textfield_equals?(browser, how, what,
|
707
|
+
textfield_equals?(browser, how, what, target, desc)
|
600
708
|
end
|
601
709
|
|
602
|
-
|
710
|
+
# Verify that *browser* is set to a url that is matched by the string or rexexp in *url*.
|
711
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
712
|
+
# @param [String, Regexp] url A string or a regular expression to match to the url of the browser..
|
713
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
714
|
+
# @return [Boolean] Returns true if the *expected* is matched in the value of the text field.
|
715
|
+
def validate_url(browser, url, desc = '')
|
716
|
+
msg = build_message("Current URL matches #{url}.", desc)
|
603
717
|
if browser.url.to_s.match(url)
|
604
|
-
passed_to_log(
|
718
|
+
passed_to_log(msg)
|
605
719
|
true
|
606
720
|
else
|
607
|
-
failed_to_log(
|
721
|
+
failed_to_log("#{msg} Actual: #{browser.url}")
|
608
722
|
end
|
609
723
|
rescue
|
610
|
-
failed_to_log("Unable to validate that
|
724
|
+
failed_to_log("Unable to validate that #{msg} '#{$!}'")
|
611
725
|
end
|
612
726
|
|
613
727
|
# @!endgroup Core
|
@@ -640,85 +754,31 @@ module Awetestlib
|
|
640
754
|
|
641
755
|
# @!endgroup AutoIT
|
642
756
|
|
643
|
-
# @!group Legacy
|
644
|
-
|
645
|
-
# Verify that link identified by *:text* exists.
|
646
|
-
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
647
|
-
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
648
|
-
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
649
|
-
# @return (see #exists?)
|
650
|
-
def validate_link_exist(browser, what, desc = '')
|
651
|
-
exists?(browser, :link, :text, what, nil, desc)
|
652
|
-
end
|
653
|
-
|
654
|
-
# Verify that link identified by *:text* does not exist.
|
655
|
-
# @param (see #validate_link_exist)
|
656
|
-
# @return (see #does_not_exist?)
|
657
|
-
def link_not_exist?(browser, what, desc = '')
|
658
|
-
does_not_exist?(browser, :link, :text, what, nil, desc)
|
659
|
-
end
|
660
|
-
|
661
|
-
alias validate_link_not_exist link_not_exist?
|
662
|
-
|
663
|
-
# Verify that div identified by *:id* is visible.
|
664
|
-
# @param (see #validate_link_exist)
|
665
|
-
# @return [Boolean] True if the element is visible.
|
666
|
-
def validate_div_visible_by_id(browser, what)
|
667
|
-
visible?(browser, :div, :id, what)
|
668
|
-
end
|
669
|
-
|
670
|
-
# Verify that div identified by *:id* is not visible.
|
671
|
-
# @param (see #validate_link_exist)
|
672
|
-
# @return [Boolean] True if the element is not visible.
|
673
|
-
def validate_div_not_visible_by_id(browser, what, desc = '')
|
674
|
-
not_visible?(browser, :div, :id, what, desc)
|
675
|
-
end
|
676
|
-
|
677
|
-
# Verify that div identified by *:text* is enabled.
|
678
|
-
# @param (see #validate_link_exist)
|
679
|
-
# @return [Boolean] True if the element is enabled.
|
680
|
-
def link_enabled?(browser, what, desc = '')
|
681
|
-
enabled?(browser, :link, :text, what, desc)
|
682
|
-
end
|
683
|
-
|
684
|
-
alias validate_link_enabled link_enabled?
|
685
|
-
|
686
|
-
# Verify that div identified by *:text* is disabled.
|
687
|
-
# @param (see #validate_link_exist)
|
688
|
-
# @return [Boolean] True if the element is disabled.
|
689
|
-
def link_disabled?(browser, what, desc = '')
|
690
|
-
disabled?(browser, :link, :text, what, desc)
|
691
|
-
end
|
692
|
-
|
693
|
-
alias validate_link_not_enabled link_disabled?
|
694
|
-
|
695
|
-
# @!endgroup Legacy
|
696
757
|
# @!group Core
|
697
758
|
|
698
|
-
def
|
699
|
-
|
700
|
-
message = "Popup: #{popup.title}"
|
701
|
-
end
|
759
|
+
def popup_is_browser?(popup, desc = '')
|
760
|
+
msg = build_message("Popup: #{popup.title} is a browser window.", desc)
|
702
761
|
if is_browser?(popup)
|
703
|
-
passed_to_log(
|
762
|
+
passed_to_log(msg)
|
704
763
|
debug_to_log("\n"+popup.text+"\n")
|
705
764
|
true
|
706
765
|
else
|
707
|
-
failed_to_log(
|
766
|
+
failed_to_log(msg)
|
708
767
|
end
|
709
768
|
rescue
|
710
|
-
failed_to_log("Unable to
|
769
|
+
failed_to_log("Unable to verify that #{msg}: '#{$!}'. (#{__LINE__})")
|
711
770
|
end
|
712
771
|
|
713
|
-
alias popup_exist
|
714
|
-
alias popup_exists
|
715
|
-
alias popup_exist?
|
716
|
-
alias
|
717
|
-
alias iepopup_exist
|
718
|
-
alias
|
719
|
-
alias iepopup_exists
|
772
|
+
alias popup_exist popup_is_browser?
|
773
|
+
alias popup_exists popup_is_browser?
|
774
|
+
alias popup_exist? popup_is_browser?
|
775
|
+
alias popup_exists? popup_is_browser?
|
776
|
+
alias iepopup_exist popup_is_browser?
|
777
|
+
alias iepopup_exist? popup_is_browser?
|
778
|
+
alias iepopup_exists popup_is_browser?
|
779
|
+
alias iepopup_exists? popup_is_browser?
|
720
780
|
|
721
|
-
#
|
781
|
+
# Verify that select list, identified by the value *what* in the attribute :id, contains text and select it if present.
|
722
782
|
def validate_list_by_id(browser, what, option, desc = '', select_if_present = true)
|
723
783
|
if select_list_includes?(browser, :id, what, option, desc)
|
724
784
|
if select_if_present
|
@@ -730,7 +790,7 @@ module Awetestlib
|
|
730
790
|
end
|
731
791
|
end
|
732
792
|
|
733
|
-
#
|
793
|
+
# Verify that select list contains text
|
734
794
|
def validate_list_by_name(browser, what, option, desc = '', select_if_present = true)
|
735
795
|
if select_list_includes?(browser, :name, what, option, desc)
|
736
796
|
if select_if_present
|
@@ -776,11 +836,8 @@ module Awetestlib
|
|
776
836
|
|
777
837
|
alias validate_link validate_text
|
778
838
|
|
779
|
-
# @!group Core
|
780
|
-
|
781
839
|
def text_in_element_equals?(browser, element, how, what, expected, desc = '')
|
782
|
-
msg
|
783
|
-
msg << " #{desc}" if desc.length > 0
|
840
|
+
msg = build_message("Expected exact text '#{expected}' in #{element} :#{how}=>#{what}.", desc)
|
784
841
|
text = ''
|
785
842
|
who = browser.element(how, what)
|
786
843
|
if who
|
@@ -799,9 +856,13 @@ module Awetestlib
|
|
799
856
|
end
|
800
857
|
|
801
858
|
def element_contains_text?(browser, element, how, what, expected, desc = '')
|
802
|
-
msg = "Element #{element} :{how}=>#{what} contains text '#{expected}'."
|
803
|
-
|
804
|
-
|
859
|
+
msg = build_message("Element #{element} :{how}=>#{what} contains text '#{expected}'.", desc)
|
860
|
+
case how
|
861
|
+
when :href
|
862
|
+
who = browser.element(how, what)
|
863
|
+
else
|
864
|
+
who = browser.link(how, what)
|
865
|
+
end
|
805
866
|
if who
|
806
867
|
text = who.text
|
807
868
|
if expected and expected.length > 0
|
@@ -829,39 +890,8 @@ module Awetestlib
|
|
829
890
|
failed_to_log("Unable to verify #{msg} '#{$!}'")
|
830
891
|
end
|
831
892
|
|
832
|
-
# @!endgroup Core
|
833
|
-
|
834
|
-
# @!group Legacy
|
835
|
-
|
836
|
-
def validate_list(browser, listId, text, message)
|
837
|
-
validate_list_by_id(browser, listId, text, message)
|
838
|
-
end
|
839
|
-
|
840
|
-
#Validate select list does not contain text
|
841
|
-
def validate_no_list(browser, id, text, desc = '')
|
842
|
-
select_list_does_not_include?(browser, :id, id, text, desc)
|
843
|
-
end
|
844
|
-
|
845
|
-
def text_in_span_equals?(browser, how, what, expected, desc = '')
|
846
|
-
text_in_element_equals?(browser, :span, how, what, expected, desc)
|
847
|
-
end
|
848
|
-
|
849
|
-
def span_contains_text?(browser, how, what, expected, desc = '')
|
850
|
-
element_contains_text?(browser, :span, how, what, expected, desc)
|
851
|
-
end
|
852
|
-
|
853
|
-
alias valid_text_in_span span_contains_text?
|
854
|
-
|
855
|
-
def validate_text_in_span_by_id(browser, id, strg = '', desc = '')
|
856
|
-
element_contains_text?(browser, :span, :id, id, strg, desc)
|
857
|
-
end
|
858
|
-
|
859
|
-
# @!endgroup Legacy
|
860
|
-
|
861
|
-
# @!group Core
|
862
|
-
|
863
893
|
def validate_select_list(browser, how, what, opt_type, list = nil, multiple = false, ignore = ['Select One'], limit = 5)
|
864
|
-
mark_testlevel("#{__method__.to_s.titleize} (#{how}=>#{what})",
|
894
|
+
mark_testlevel("#{__method__.to_s.titleize} (#{how}=>#{what})", 0)
|
865
895
|
ok = true
|
866
896
|
select_list = browser.select_list(how, what)
|
867
897
|
options = select_list.options
|
@@ -961,8 +991,7 @@ module Awetestlib
|
|
961
991
|
alias validate_select_list_selections validate_selected_options
|
962
992
|
|
963
993
|
def string_contains?(strg, target, desc = '')
|
964
|
-
msg = "String '#{strg}' contains '#{target}'."
|
965
|
-
msg << " '#{desc}' " if desc.length > 0
|
994
|
+
msg = build_message("String '#{strg}' contains '#{target}'.", desc)
|
966
995
|
if strg.match(target)
|
967
996
|
passed_to_log("#{msg} (#{__LINE__})")
|
968
997
|
true
|
@@ -975,8 +1004,7 @@ module Awetestlib
|
|
975
1004
|
alias validate_string_contains string_contains?
|
976
1005
|
|
977
1006
|
def string_does_not_contain?(strg, target, desc = '')
|
978
|
-
msg = "String '#{strg}' does not contain '#{target}'."
|
979
|
-
msg << " '#{desc}' " if desc.length > 0
|
1007
|
+
msg = build_message("String '#{strg}' does not contain '#{target}'.", desc)
|
980
1008
|
if strg.match(target)
|
981
1009
|
failed_to_log("#{msg} (#{__LINE__})")
|
982
1010
|
true
|
@@ -1012,8 +1040,7 @@ module Awetestlib
|
|
1012
1040
|
end
|
1013
1041
|
|
1014
1042
|
def textfield_does_not_equal?(browser, how, what, expected, desc = '')
|
1015
|
-
msg = "Text field #{how}=>#{what} does not equal '#{expected}'"
|
1016
|
-
msg << " #{desc}" if desc.length > 0
|
1043
|
+
msg = build_message("Text field #{how}=>#{what} does not equal '#{expected}'", desc)
|
1017
1044
|
if not browser.text_field(how, what).value == expected
|
1018
1045
|
passed_to_log(msg)
|
1019
1046
|
true
|
@@ -1028,116 +1055,6 @@ module Awetestlib
|
|
1028
1055
|
|
1029
1056
|
# @!endgroup Core
|
1030
1057
|
|
1031
|
-
# @!group Legacy
|
1032
|
-
|
1033
|
-
def validate_textfield_not_value_by_name(browser, name, value, desc = '')
|
1034
|
-
textfield_does_not_equal?(browser, :name, name, value, desc)
|
1035
|
-
end
|
1036
|
-
|
1037
|
-
alias validate_textfield_no_value_by_name validate_textfield_not_value_by_name
|
1038
|
-
|
1039
|
-
def validate_textfield_not_value_by_id(browser, id, value, desc = '')
|
1040
|
-
textfield_does_not_equal?(browser, :id, id, value, desc)
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
alias validate_textfield_no_value_by_id validate_textfield_not_value_by_id
|
1044
|
-
|
1045
|
-
def validate_textfield_empty_by_name(browser, name, message = '')
|
1046
|
-
validate_textfield_empty(browser, :name, name, message)
|
1047
|
-
end
|
1048
|
-
|
1049
|
-
def validate_textfield_empty_by_id(browser, id, message = '')
|
1050
|
-
validate_textfield_empty(browser, :id, id, message)
|
1051
|
-
end
|
1052
|
-
|
1053
|
-
def validate_textfield_empty_by_title(browser, title, message = '')
|
1054
|
-
validate_textfield_empty(browser, :title, title, message)
|
1055
|
-
end
|
1056
|
-
|
1057
|
-
def validate_textfield_value_by_name(browser, name, expected, desc = '')
|
1058
|
-
textfield_equals?(browser, :name, name, expected, desc)
|
1059
|
-
end
|
1060
|
-
|
1061
|
-
def validate_textfield_value_by_id(browser, id, expected, desc = '')
|
1062
|
-
textfield_equals?(browser, :id, id, expected, desc)
|
1063
|
-
end
|
1064
|
-
|
1065
|
-
def validate_textfield_visible_by_name(browser, strg, desc = '')
|
1066
|
-
visible?(browser, :text_field, :name, strg, desc)
|
1067
|
-
end
|
1068
|
-
|
1069
|
-
alias visible_textfield_by_name validate_textfield_visible_by_name
|
1070
|
-
|
1071
|
-
def validate_textfield_disabled_by_name(browser, strg, desc = '')
|
1072
|
-
disabled?(browser, :text_field, :name, strg, desc)
|
1073
|
-
end
|
1074
|
-
|
1075
|
-
alias disabled_textfield_by_name validate_textfield_disabled_by_name
|
1076
|
-
|
1077
|
-
def validate_textfield_enabled_by_name(browser, strg, desc = '')
|
1078
|
-
enabled?(browser, :text_field, :name, strg, desc)
|
1079
|
-
end
|
1080
|
-
|
1081
|
-
alias enabled_textfield_by_name validate_textfield_enabled_by_name
|
1082
|
-
|
1083
|
-
def validate_textfield_not_visible_by_name(browser, strg, desc = '')
|
1084
|
-
not_visible?(browser, :text_field, :name, strg, desc)
|
1085
|
-
end
|
1086
|
-
|
1087
|
-
alias visible_no_textfield_by_name validate_textfield_not_visible_by_name
|
1088
|
-
|
1089
|
-
def validate_radio_not_set(browser, what, desc = '')
|
1090
|
-
not_set?(browser, :id, what, desc)
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
alias validate_not_radioset validate_radio_not_set
|
1094
|
-
|
1095
|
-
def radio_is_set?(browser, what, desc = '')
|
1096
|
-
set?(browser, :id, what, desc)
|
1097
|
-
end
|
1098
|
-
|
1099
|
-
alias validate_radioset radio_is_set?
|
1100
|
-
alias validate_radio_set radio_is_set?
|
1101
|
-
|
1102
|
-
def validate_radioset_by_name(browser, what, desc = '')
|
1103
|
-
set?(browser, :name, what, desc)
|
1104
|
-
end
|
1105
|
-
|
1106
|
-
def checked_by_id?(browser, strg, desc = '')
|
1107
|
-
checked?(browser, :id, strg, desc)
|
1108
|
-
end
|
1109
|
-
|
1110
|
-
alias validate_check checked_by_id?
|
1111
|
-
alias checkbox_is_checked? checked_by_id?
|
1112
|
-
|
1113
|
-
def checkbox_is_enabled?(browser, strg, desc = '')
|
1114
|
-
enabled?(browser, :checkbox, :id, strg, desc)
|
1115
|
-
end
|
1116
|
-
|
1117
|
-
alias validate_check_enabled checkbox_is_enabled?
|
1118
|
-
|
1119
|
-
def checkbox_is_disabled?(browser, strg, desc = '')
|
1120
|
-
disabled?(browser, :checkbox, :id, strg, desc)
|
1121
|
-
end
|
1122
|
-
|
1123
|
-
alias validate_check_disabled checkbox_is_disabled?
|
1124
|
-
|
1125
|
-
def validate_check_by_class(browser, strg, desc)
|
1126
|
-
checked?(browser, :class, strg, desc)
|
1127
|
-
end
|
1128
|
-
|
1129
|
-
def checkbox_not_checked?(browser, strg, desc)
|
1130
|
-
not_checked?(browser, :id, strg, desc)
|
1131
|
-
end
|
1132
|
-
|
1133
|
-
alias validate_not_check checkbox_not_checked?
|
1134
|
-
|
1135
|
-
def validate_image(browser, source, desc = '', nofail = false)
|
1136
|
-
exists?(browser, :image, :src, desc)
|
1137
|
-
end
|
1138
|
-
|
1139
|
-
# @!endgroup Legacy
|
1140
|
-
|
1141
1058
|
# @!group Deprecated
|
1142
1059
|
# @deprecated
|
1143
1060
|
def self.included(mod)
|