awetestlib 0.1.13-x86-mingw32 → 0.1.14-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,49 +1,26 @@
1
1
  module Awetestlib
2
2
  module Regression
3
+ # Contains methods to verify content, accessibility, or appearance of page elements.
3
4
  module Validations
4
5
 
5
- def self.included(mod)
6
- # puts "RegressionSupport::Validations extended by #{mod}"
7
- end
8
-
9
- def modal_exists?(browser, button = nil)
10
- rtrn = nil
11
- if @browserAbbrev == 'IE'
12
- Timeout::timeout(2) do
13
- begin
14
- if browser.enabled_popup
15
- hwnd = browser.enabled_popup(5)
16
- debug_to_log("Modal popup with handle #{hwnd} found. (#{__LINE__})")
17
- wc = WinClicker.new
18
- wc.makeWindowActive(hwnd)
19
- rtrn = wc.getWindowTitle(hwnd)
20
- if button
21
- wc.clickWindowsButton_hWnd(hwnd, button)
22
- end
23
- wc = nil
24
- end
25
- rescue Timeout::Error
26
- debug_to_log("No Modal popup found. (#{__LINE__})")
27
- return rtrn
28
- end
29
- return rtrn
30
- end
31
- rtrn
32
- else
33
- rtrn
34
- end
35
- end
36
-
37
- def validate_message(browser, message)
38
- if validate(browser, @myName, __LINE__)
39
- message_to_log(message)
40
- end
41
- end
42
-
6
+ # @!group Core
7
+
8
+ # Verify that element style attribute contains expected value in style *type*.
9
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
10
+ # @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
11
+ # Some common values are :link, :button, :image, :div, :span.
12
+ # @param [Symbol] how The element attribute used to identify the specific element.
13
+ # Valid values depend on the kind of element.
14
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
15
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
16
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
17
+ # @param [String] type The name of the style type (sub-attribute) where *expected* is to be found.
18
+ # @param [String] expected The value in *type* expected.
19
+ # @return [Boolean] True if the style type contains the expected value
20
+ #
43
21
  def validate_style_value(browser, element, how, what, type, expected, desc = '')
44
22
  #TODO: works only with watir-webdriver
45
- msg = "Expected CSS style #{type} value '#{expected}' in #{element} with #{how} = #{what}"
46
- msg << " #{desc}" if desc.length > 0
23
+ msg = build_message("Expected Style #{type} value '#{expected}' in #{element} with #{how} = #{what}", desc)
47
24
  case element
48
25
  when :link
49
26
  actual = browser.link(how => what).style type
@@ -55,24 +32,30 @@ module Awetestlib
55
32
  actual = browser.span(how => what).style type
56
33
  when :div
57
34
  actual = browser.div(how => what).style type
35
+ else
36
+ if browser.element(how => what).responds_to?("style")
37
+ actual = browser.element(how => what).style type
38
+ else
39
+ failed_to_log("#{msg}: Element #{element} does not reponds to style command.")
40
+ end
58
41
  end
59
42
  if expected == actual
60
43
  passed_to_log(msg)
44
+ true
61
45
  else
62
46
  failed_to_log(msg)
63
47
  end
64
48
  rescue
65
- failed_to_log( "Unable to validate #{msg} '#{$!}'")
49
+ failed_to_log("Unable to verify that #{msg} '#{$!}'")
66
50
  end
67
51
 
68
- ##### begin core validation methods #####
69
-
70
- def arrays_match?(exp, act, dir, col, org = nil)
52
+ # @todo Clarify and rename
53
+ def arrays_match?(exp, act, dir, col, org = nil, desc = '')
71
54
  if exp == act
72
- passed_to_log("Click on #{dir} column '#{col}' produces expected sorted list.")
55
+ passed_to_log("Click on #{dir} column '#{col}' produces expected sorted list. #{desc}")
73
56
  true
74
57
  else
75
- failed_to_log("Click on #{dir} column '#{col}' fails to produce expected sorted list.")
58
+ failed_to_log("Click on #{dir} column '#{col}' fails to produce expected sorted list. #{desc}")
76
59
  debug_to_log("Original order ['#{org.join("', '")}']") if org
77
60
  debug_to_log("Expected order ['#{exp.join("', '")}']")
78
61
  debug_to_log(" Actual order ['#{act.join("', '")}']")
@@ -81,9 +64,19 @@ module Awetestlib
81
64
 
82
65
  alias arrays_match arrays_match?
83
66
 
67
+ # Verify that a DOM element is enabled.
68
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
69
+ # @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
70
+ # Some common values are :link, :button, :image, :div, :span.
71
+ # @param [Symbol] how The element attribute used to identify the specific element.
72
+ # Valid values depend on the kind of element.
73
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
74
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
75
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
76
+ # @return [Boolean] Returns true if the element is enabled.
84
77
  def enabled?(browser, element, how, what, desc = '')
85
- msg = "#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled.}"
86
- msg << " #{desc}" if desc.length > 0
78
+ #TODO: handle identification of element with value as well as other attribute. see exists?
79
+ msg = build_message("#{element.to_s.titlecase} by #{how}=>'#{what}' is enabled.}", desc)
87
80
  case element
88
81
  when :textfield, :textarea, :text_area, :text_field
89
82
  rtrn = browser.text_field(how, what).enabled? and not browser.text_field(how, what).readonly?
@@ -105,30 +98,12 @@ module Awetestlib
105
98
 
106
99
  alias validate_enabled enabled?
107
100
 
108
- def date_string_equals?(actual, expected, desc = '', fail_on_format = true)
109
- rtrn = false
110
- msg = "Assert actual date '#{actual}' equals expected date '#{expected}'. #{desc} "
111
- if actual == expected
112
- rtrn = true
113
- elsif DateTime.parse(actual).to_s == DateTime.parse(expected).to_s
114
- msg << " with different formatting. "
115
- if not fail_on_format
116
- rtrn = true
117
- end
118
- end
119
- msg << " #{desc}" if desc.length > 0
120
- if rtrn
121
- passed_to_log("#{msg}")
122
- else
123
- failed_to_log("#{msg}")
124
- end
125
- rtrn
126
- rescue
127
- failed_to_log("Unable to #{msg}. #{$!}")
128
- end
129
-
101
+ # Verify that a DOM element is disabled.
102
+ # @param (see #enabled?)
103
+ # @return [Boolean] Returns true if the element is disabled.
130
104
  def disabled?(browser, element, how, what, desc = '')
131
- msg = "#{element.to_s.titlecase} by #{how}=>'#{what}' is disabled. #{desc}"
105
+ #TODO: handle identification of element with value as well as other attribute. see exists?
106
+ msg = build_message("#{element.to_s.titlecase} by #{how}=>'#{what}' is disabled.", desc)
132
107
  case element
133
108
  when :textfield, :textarea, :text_area, :text_field
134
109
  rtrn = browser.text_field(how, what).disabled? ||
@@ -140,11 +115,9 @@ module Awetestlib
140
115
  when :radio
141
116
  rtrn = browser.radio(how, what).disabled?
142
117
  when :button
143
- rtrn = browser.button(how, value).disabled?
118
+ rtrn = browser.button(how, what).disabled?
144
119
  else
145
- msg = "#{__method__} does not yet support '#{element}'. #{desc}"
146
- debug_to_log(msg)
147
- raise msg
120
+ rtrn = browser.element(how, what).disabled?
148
121
  end
149
122
  if rtrn
150
123
  passed_to_log("#{msg}")
@@ -160,20 +133,12 @@ module Awetestlib
160
133
  alias validate_not_enabled disabled?
161
134
  alias validate_disabled disabled?
162
135
 
163
- def verify_text_in_table_with_text(table, text, value)
164
- #TODO This needs clarification, renaming
165
- msg = "Table :id=>#{table.id} with text '#{text} contains '#{value}."
166
- index = get_index_of_row_with_text(table, text)
167
- if table[index].text =~ value
168
- passed_to_log(msg)
169
- true
170
- else
171
- failed_to_log(msg)
172
- end
173
- end
174
-
136
+ # Verify that a DOM element is visible.
137
+ # @param (see #enabled?)
138
+ # @return [Boolean] Returns true if the element is visible.
175
139
  def visible?(browser, element, how, what, desc = '')
176
- msg = "#{element.to_s.titlecase} #{how}=>'#{what}' is visible. #{desc}"
140
+ #TODO: handle identification of element with value as well as other attribute. see exists?
141
+ msg = build_message("#{element.to_s.titlecase} #{how}=>'#{what}' is visible.", desc)
177
142
  rtrn = false
178
143
  case how
179
144
  when :index
@@ -198,8 +163,12 @@ module Awetestlib
198
163
 
199
164
  alias validate_visible visible?
200
165
 
166
+ # Verify that a DOM element is not visible.
167
+ # @param (see #enabled?)
168
+ # @return [Boolean] Returns true if the element is not visible.
201
169
  def not_visible?(browser, element, how, what, desc = '')
202
- msg = "#{element.to_s.titlecase} #{how}=>'#{what}' is not visible. #{desc}"
170
+ #TODO: handle identification of element with value as well as other attribute. see exists?
171
+ msg = build_message("#{element.to_s.titlecase} #{how}=>'#{what}' is not visible.", desc)
203
172
  rtrn = false
204
173
  case how
205
174
  when :index
@@ -224,47 +193,62 @@ module Awetestlib
224
193
 
225
194
  alias validate_not_visible not_visible?
226
195
 
196
+ # Verify that a checkbox is checked.
197
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
198
+ # @param [Symbol] how The element attribute used to identify the specific element.
199
+ # Valid values depend on the kind of element.
200
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
201
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
202
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
203
+ # @return [Boolean] Returns true if the checkbox is checked.
227
204
  def checked?(browser, how, what, desc = '')
228
- msg = "Checkbox #{how}=>#{what} is checked."
229
- msg << " #{desc}" if desc.length > 0
205
+ #TODO: handle identification of element with value as well as other attribute. see exists?
206
+ msg = build_message("Checkbox #{how}=>#{what} is checked.", desc)
230
207
  if browser.checkbox(how, what).checked?
231
- if validate(browser, @myName, __LINE__)
232
- passed_to_log(msg)
233
- true
234
- end
208
+ passed_to_log(msg)
209
+ true
235
210
  else
236
211
  failed_to_log(msg)
237
212
  end
238
213
  rescue
239
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
214
+ failed_to_log("Unable to verify that #{msg}: '#{$!}'")
240
215
  end
241
216
 
242
217
  alias checkbox_checked? checked?
243
218
  alias checkbox_set? checked?
244
219
 
220
+ # Verify that a checkbox is not checked.
221
+ # @param (see #checked?)
222
+ # @return [Boolean] Returns true if the checkbox is not checked.
245
223
  def not_checked?(browser, how, what, desc = '')
246
- msg = "Checkbox #{how}=>#{what} is not checked."
247
- msg << " #{desc}" if desc.length > 0
224
+ #TODO: handle identification of element with value as well as other attribute. see exists?
225
+ msg = build_message("Checkbox #{how}=>#{what} is not checked.", desc)
248
226
  if not browser.checkbox(how, what).checked?
249
- if validate(browser, @myName, __LINE__)
250
- passed_to_log(msg)
251
- true
252
- end
227
+ passed_to_log(msg)
228
+ true
253
229
  else
254
230
  failed_to_log(msg)
255
231
  end
256
232
  rescue
257
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
233
+ failed_to_log("Unable to verify that #{msg}: '#{$!}'")
258
234
  end
259
235
 
260
236
  alias checkbox_checked? checked?
261
237
  alias checkbox_set? checked?
262
238
 
239
+ # Verify that a DOM element exists on the page.
240
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
241
+ # @param [Symbol] how The element attribute used to identify the specific element.
242
+ # Valid values depend on the kind of element.
243
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
244
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
245
+ # @param [String, Regexp] value A string or a regular expression to be found in the value attribute of the element.
246
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
247
+ # @return [Boolean] True if the element exists.
263
248
  def exists?(browser, element, how, what, value = nil, desc = '')
264
- msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
265
- msg << "and value=>'#{value}' " if value
266
- msg << "exists"
267
- e = get_element(browser, element, how, what, value)
249
+ msg2 = "and value=>'#{value}' " if value
250
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists.', desc)
251
+ e = get_element(browser, element, how, what, value)
268
252
  if e
269
253
  passed_to_log("#{msg}? #{desc}")
270
254
  true
@@ -272,14 +256,15 @@ module Awetestlib
272
256
  failed_to_log("#{msg}? #{desc} [#{get_callers(1)}]")
273
257
  end
274
258
  rescue
275
- failed_to_log("Unable to determine if #{msg}. #{desc} '#{$!}' [#{get_callers(1)}]")
259
+ failed_to_log("Unable to verify that #{msg}. #{desc} '#{$!}' [#{get_callers(1)}]")
276
260
  end
277
261
 
262
+ # Verify that a DOM element does not exist on the page.
263
+ # @param (see #exists?)
264
+ # @return [Boolean] True if the element does not exist.
278
265
  def does_not_exist?(browser, element, how, what, value = nil, desc = '')
279
- msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
280
- msg << "and value=>'#{value}' " if value
281
- msg << "does not exist."
282
- msg << " #{desc}" if desc.length > 0
266
+ msg2 = "and value=>'#{value}' " if value
267
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'does not exist.', desc)
283
268
  if browser.element(how, what).exists?
284
269
  failed_to_log(msg)
285
270
  else
@@ -292,15 +277,15 @@ module Awetestlib
292
277
 
293
278
  alias not_exist? does_not_exist?
294
279
 
280
+ # Verify that a radio button is set.
281
+ # @param (see #checked?)
282
+ # @return [Boolean] Returns true if the radio button is set.
295
283
  def set?(browser, how, what, desc = '', no_fail = false)
296
- #TODO Needs to handle radio value as well
297
- msg = "Radio #{how}=>#{what} is selected."
298
- msg << " #{desc}" if desc.length > 0
284
+ #TODO: handle identification of element with value as well as other attribute. see radio_with_value_set?
285
+ msg = build_message("Radio #{how}=>#{what} is selected.", desc)
299
286
  if browser.radio(how, what).set?
300
- if validate(browser, @myName, __LINE__)
301
- passed_to_log(msg)
302
- true
303
- end
287
+ passed_to_log(msg)
288
+ true
304
289
  else
305
290
  if no_fail
306
291
  passed_to_log("Radio #{how}=>#{what} is not selected.")
@@ -309,22 +294,22 @@ module Awetestlib
309
294
  end
310
295
  end
311
296
  rescue
312
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
297
+ failed_to_log("Unable to verify taht #{msg}: '#{$!}'")
313
298
  end
314
299
 
315
300
  alias radio_set? set?
316
301
  alias radio_checked? set?
317
302
  alias radio_selected? set?
318
303
 
304
+ # Verify that a radio button is not set.
305
+ # @param (see #checked?)
306
+ # @return [Boolean] Returns true if the radio button is not set.
319
307
  def not_set?(browser, how, what, desc = '', no_fail = false)
320
- #TODO Needs to handle radio value as well
321
- msg = "Radio #{how}=>#{what} is not selectedd."
322
- msg << " #{desc}" if desc.length > 0
308
+ #TODO: handle identification of element with value as well as other attribute. see radio_with_value_set?
309
+ msg = build_message("Radio #{how}=>#{what} is not selected.", desc)
323
310
  if not browser.radio(how, what).set?
324
- if validate(browser, @myName, __LINE__)
325
- passed_to_log(msg)
326
- true
327
- end
311
+ passed_to_log(msg)
312
+ true
328
313
  else
329
314
  if no_fail
330
315
  passed_to_log("Radio #{how}=>#{what} is not selected.")
@@ -333,37 +318,54 @@ module Awetestlib
333
318
  end
334
319
  end
335
320
  rescue
336
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
321
+ failed_to_log("Unable to verify that #{msg}: '#{$!}'")
337
322
  end
338
323
 
339
324
  alias radio_not_set? not_set?
340
325
  alias radio_not_checked? not_set?
341
326
  alias radio_not_selected? not_set?
342
327
 
328
+ # Verify that a radio button, identified by both the value (*what*) in attribute *how*
329
+ # and the *value* in its value attribute, is set.
330
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
331
+ # @param [Symbol] how The element attribute used to identify the specific element.
332
+ # Valid values depend on the kind of element.
333
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
334
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
335
+ # @param [String, Regexp] value A string or a regular expression to be found in the value attribute of the element.
336
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
337
+ # @return [Boolean] Returns true if the radio button is set.
343
338
  def radio_with_value_set?(browser, how, what, value, desc = '', no_fail = false)
344
- msg = "Radio #{how}=>#{what} :value=>#{value} is selected."
345
- msg << " #{desc}" if desc.length > 0
339
+ msg2 = 'not' if no_fail
340
+ msg = build_message("Radio #{how}=>#{what} :value=>#{value} is", msg2, 'selected.', desc)
346
341
  if browser.radio(how, what, value).set?
347
- if validate(browser, @myName, __LINE__)
348
- passed_to_log(msg)
349
- true
350
- end
342
+ passed_to_log(msg)
343
+ true
351
344
  else
352
345
  if no_fail
353
- passed_to_log("Radio #{how}=>#{what} :value=>#{value} is not selected.")
346
+ passed_to_log(msg)
354
347
  else
355
348
  failed_to_log(msg)
356
349
  end
357
350
  end
358
351
  rescue
359
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
352
+ failed_to_log("Unable to verify that #{msg}: '#{$!}'")
360
353
  end
361
354
 
362
355
  alias radio_set_with_value? radio_with_value_set?
363
356
 
357
+ # Verify that a select list, identified by the value (*what*) in attribute *how*, contains an option with the
358
+ # value in *option*.
359
+ # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
360
+ # @param [Symbol] how The element attribute used to identify the specific element.
361
+ # Valid values depend on the kind of element.
362
+ # Common values: :text, :id, :title, :name, :class, :href (:link only)
363
+ # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
364
+ # @param [String, Regexp] option A string or a regular expression to be found in the value attribute of the element.
365
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
366
+ # @return [Boolean] Returns true if the option is found.
364
367
  def select_list_includes?(browser, how, what, option, desc = '')
365
- msg = "Select list #{how}=>#{what} includes option '#{option}'."
366
- msg << " #{desc}" if desc.length > 0
368
+ msg = build_message("Select list #{how}=>#{what} includes option '#{option}'.", desc)
367
369
  select_list = browser.select_list(how, what)
368
370
  options = select_list.options
369
371
  if option
@@ -382,9 +384,12 @@ module Awetestlib
382
384
  alias validate_select_list_contains select_list_includes?
383
385
  alias select_list_contains? select_list_includes?
384
386
 
387
+ # Verify that a select list, identified by the value (*what*) in attribute *how*, contains an option with the
388
+ # value in *option*.
389
+ # @param (see #select_list_includes?)
390
+ # @return [Boolean] Returns true if the option is not found.
385
391
  def select_list_does_not_include?(browser, how, what, option, desc = '')
386
- msg = "Select list #{how}=>#{what} does not include option '#{option}'."
387
- msg << " #{desc}" if desc.length > 0
392
+ msg = build_message("Select list #{how}=>#{what} does not include option '#{option}'.", desc)
388
393
  select_list = browser.select_list(how, what)
389
394
  options = select_list.options
390
395
  if option
@@ -400,9 +405,14 @@ module Awetestlib
400
405
  failed_to_log("Unable to verify #{msg}. '#{$!}'")
401
406
  end
402
407
 
403
- def string_equals?(actual, target, desc = '')
404
- msg = "Assert actual '#{actual}' equals expected '#{target}'. #{desc} "
405
- if actual == target
408
+ # Compare strings for exact match and log results
409
+ # @param [String] actual The actual value as found in the application.
410
+ # @param [String] expected The value expected to be found.
411
+ # @param [String] desc Contains a message or description intended to appear in the log and/or report output
412
+ # @return [Boolean] Returns true if actual exactly matches expected.
413
+ def string_equals?(actual, expected, desc = '')
414
+ msg = build_message("Actual string '#{actual}' equals expected '#{expected}'.", desc)
415
+ if expected == expected
406
416
  passed_to_log("#{msg}")
407
417
  true
408
418
  else
@@ -417,10 +427,12 @@ module Awetestlib
417
427
  alias text_equals string_equals?
418
428
  alias text_equals? string_equals?
419
429
 
420
- def string_does_not_equal?(strg, target, desc = '')
421
- msg = "String '#{strg}' does not equal '#{target}'."
422
- msg << " '#{desc}' " if desc.length > 0
423
- if strg == target
430
+ # Compare strings for no match and log results
431
+ # @param (see #string_equals?)
432
+ # @return [Boolean] Returns true if actual does not match expected.
433
+ def string_does_not_equal?(actual, expected, desc = '')
434
+ msg = build_message("Actual string '#{actual}' does not equal expected '#{expected}'.", desc)
435
+ if actual == expected
424
436
  failed_to_log("#{msg} (#{__LINE__})")
425
437
  true
426
438
  else
@@ -431,6 +443,35 @@ module Awetestlib
431
443
  alias validate_string_not_equal string_does_not_equal?
432
444
  alias validate_string_does_not_equal string_does_not_equal?
433
445
 
446
+ # Verify that date strings represent the same date, allowing for format differences.
447
+ # Compare strings for no match and log results
448
+ # @param (see #string_equals?)
449
+ # @param [Boolean] fail_on_format If set to true method will fail if the formats differ
450
+ # @return [Boolean] Returns true if actual does not match expected.
451
+ def date_string_equals?(actual, expected, desc = '', fail_on_format = true)
452
+ rtrn = false
453
+ if actual == expected
454
+ rtrn = true
455
+ elsif DateTime.parse(actual).to_s == DateTime.parse(expected).to_s
456
+ msg2 "with different formatting. "
457
+ unless fail_on_format
458
+ rtrn = true
459
+ end
460
+ end
461
+ msg = build_message("Actual date '#{actual}' equals expected date '#{expected}'.", msg2, desc)
462
+ if rtrn
463
+ passed_to_log("#{msg}")
464
+ else
465
+ failed_to_log("#{msg}")
466
+ end
467
+ rtrn
468
+ rescue
469
+ failed_to_log("Unable to verify that #{msg}. #{$!}")
470
+ end
471
+
472
+ # Verify that a DOM element is in read-only state.
473
+ # @param (see #enabled?)
474
+ # @return [Boolean] Returns true if the element is in read-only state.
434
475
  def read_only?(browser, element, how, what, value = nil, desc = '')
435
476
  msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
436
477
  msg << "and value=>'#{value}' " if value
@@ -448,6 +489,9 @@ module Awetestlib
448
489
  failed_to_log("Unable to determine if #{msg}. #{desc} '#{$!}' [#{get_callers(1)}]")
449
490
  end
450
491
 
492
+ # Verify that a DOM element is not in read-only state.
493
+ # @param (see #enabled?)
494
+ # @return [Boolean] Returns true if the element is not in read-only state.
451
495
  def not_read_only?(browser, element, how, what, value = nil, desc = '')
452
496
  msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
453
497
  msg << "and value=>'#{value}' " if value
@@ -465,23 +509,110 @@ module Awetestlib
465
509
  failed_to_log("Unable to determine if #{msg}. #{desc} '#{$!}' [#{get_callers(1)}]")
466
510
  end
467
511
 
512
+ # Verify that a DOM element is ready, i.e., both exists and is enabled.
513
+ # @param (see #exists?)
514
+ # @return [Boolean] Returns true if the element is ready.
468
515
  def ready?(browser, element, how, what, value = '', desc = '')
469
- msg = "#{element.to_s.titlecase} with #{how}=>'#{what}' "
470
- msg << "and value=>'#{value}' " if value
516
+ msg2 = "and value=>'#{value}' " if value
517
+ msg = build_message("#{element.to_s.titlecase} with #{how}=>'#{what}' ", msg2, 'exists and is enabled.', desc)
471
518
  e = get_element(browser, element, how, what, value)
472
519
  if e and e.enabled?
473
- passed_to_log("#{msg}? #{desc}")
520
+ passed_to_log(msg)
474
521
  true
475
522
  else
476
- failed_to_log("#{msg}? #{desc} [#{get_callers(1)}]")
523
+ failed_to_log(msg)
477
524
  end
478
525
  rescue
479
- failed_to_log("Unable to determine if #{msg}. #{desc} '#{$!}' [#{get_callers(1)}]")
526
+ failed_to_log("Unable to determine if #{msg}. '#{$!}' [#{get_callers(1)}]")
527
+ end
528
+
529
+ def textfield_equals?(browser, how, what, expected, desc = '')
530
+ msg = build_message("Expected value to equal '#{expected}' in textfield #{how}=>'#{what}'.", desc)
531
+ actual = browser.text_field(how, what).value
532
+ if actual.is_a?(Array)
533
+ actual = actual[0].to_s
534
+ end
535
+ if actual == expected
536
+ passed_to_log(msg)
537
+ true
538
+ else
539
+ act_s = actual.strip
540
+ exp_s = expected.strip
541
+ if act_s == exp_s
542
+ passed_to_log("#{msg} (stripped)")
543
+ true
544
+ else
545
+ debug_to_report(
546
+ "#{__method__} (spaces underscored):\n "+
547
+ "expected:[#{expected.gsub(' ', '_')}] (#{expected.length})\n "+
548
+ "actual:[#{actual.gsub(' ', '_')}] (#{actual.length}) (spaces underscored)"
549
+ )
550
+ failed_to_log("#{msg}. Found: '#{actual}'")
551
+ end
552
+ end
553
+ rescue
554
+ failed_to_log("Unable to verify that #{msg}: '#{$!}")
555
+ end
556
+
557
+ alias validate_textfield_value textfield_equals?
558
+ alias text_field_equals? textfield_equals?
559
+
560
+ def textfield_contains?(browser, how, what, value, desc = '')
561
+ msg = build_message("Text field #{how}=>#{what} contains '#{value}'.", desc)
562
+ contents = browser.text_field(how, what).value
563
+ if contents =~ /#{value}/
564
+ passed_to_log(msg)
565
+ true
566
+ else
567
+ failed_to_log("#{msg} Contents: '#{contents}'")
568
+ end
569
+ rescue
570
+ failed_to_log("Unable to verify that #{msg} '#{$!}'")
571
+ end
572
+
573
+ def textfield_empty?(browser, how, what, desc = '')
574
+ msg = "Text field #{how}=>#{what} is empty."
575
+ msg << desc if desc.length > 0
576
+ contents = browser.text_field(how, what).value
577
+ if contents.to_s.length == 0
578
+ passed_to_log(msg)
579
+ true
580
+ else
581
+ failed_to_log("#{msg} Contents: '#{contents}'")
582
+ end
583
+ rescue
584
+ failed_to_log("Unable to verify that #{msg} '#{$!}'")
585
+ end
586
+
587
+ alias validate_textfield_empty textfield_empty?
588
+ alias text_field_empty? textfield_empty?
589
+
590
+ def validate_textfield_dollar_value(browser, how, what, expected, with_cents = true, desc = '')
591
+ desc << " Dollar formatting"
592
+ if with_cents
593
+ expected << '.00' if not expected =~ /\.00$/
594
+ desc << ' without cents.'
595
+ else
596
+ expected.gsub!(/\.00$/, '')
597
+ desc << ' with cents.'
598
+ end
599
+ textfield_equals?(browser, how, what, expected, desc)
600
+ end
601
+
602
+ def validate_url(browser, url, message = '')
603
+ if browser.url.to_s.match(url)
604
+ passed_to_log('Found "'+url.to_s+'" ' + message)
605
+ true
606
+ else
607
+ failed_to_log('Did not find "'+url.to_s+'" ' + message + " (#{__LINE__})")
608
+ end
609
+ rescue
610
+ failed_to_log("Unable to validate that current url is '#{url}': '#{$!}'. (#{__LINE__})")
480
611
  end
481
612
 
482
- ##### end core validation methods #####
613
+ # @!endgroup Core
483
614
 
484
- ##### begin methods using @ai #####
615
+ # @!group AutoIT
485
616
 
486
617
  def window_exists?(title)
487
618
  title = translate_popup_title(title)
@@ -507,75 +638,63 @@ module Awetestlib
507
638
 
508
639
  alias window_no_exists window_does_not_exist?
509
640
 
510
- ##### end methods using @ai #####
641
+ # @!endgroup AutoIT
511
642
 
512
- ##### backward compatible methods #####
643
+ # @!group Legacy
513
644
 
514
- def validate_link_exist(browser, link, logit = true, desc = '')
515
- exists?(browser, :link, :text, link, nil, desc)
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)
516
652
  end
517
653
 
518
- def link_not_exist?(browser, link, desc = '')
519
- does_not_exist?(browser, :link, :text, link, nil, desc)
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)
520
659
  end
521
660
 
522
661
  alias validate_link_not_exist link_not_exist?
523
662
 
524
- def validate_div_visible_by_id(browser, strg)
525
- visible?(browser, :div, :id, strg)
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)
526
668
  end
527
669
 
528
- def validate_div_not_visible_by_id(browser, strg, desc = '')
529
- not_visible?(browser, :div, :id, strg, desc)
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)
530
675
  end
531
676
 
532
- ##### end backward compatible methods #####
533
-
534
-
535
- def link_enabled?(browser, strg)
536
- #TODO Use enabled?()
537
- count = string_count_in_string(browser.text, strg)
538
- if count > 0
539
- if browser.link(:text, strg).enabled?
540
- if validate(browser, @myName, __LINE__)
541
- passed_to_log(strg + " is enabled. (#{__LINE__})")
542
- true
543
- end
544
- else
545
- failed_to_log(strg + " is not enabled.")
546
- end
547
- else
548
- failed_to_log("Link '#{strg.to_s}' (by :text) not found. Cannot validate if enabled. (#{__LINE__}) " + desc)
549
- end
550
- rescue
551
- failed_to_log("Unable to validate that link with :text '#{text}' is enabled: '#{$!}'. (#{__LINE__})")
552
- debug_to_log("#{strg} appears #{count} times in browser.text.")
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)
553
682
  end
554
683
 
555
684
  alias validate_link_enabled link_enabled?
556
685
 
557
- def link_disabled?(browser, strg)
558
- #TODO use disabled?()
559
- count = string_count_in_string(browser.text, strg)
560
- if count > 0
561
- if browser.link(:text, strg).enabled?
562
- if validate(browser, @myName, __LINE__)
563
- failed_to_log(strg + " is enabled. (#{__LINE__})")
564
- end
565
- else
566
- passed_to_log(strg + " is not enabled.")
567
- true
568
- end
569
- else
570
- failed_to_log("Link '#{strg.to_s}' (by :text) not found. Cannot validate if disabled. (#{__LINE__}) " + desc)
571
- end
572
- rescue
573
- failed_to_log("Unable to validate that link with :text '#{text}' is enabled: '#{$!}'. (#{__LINE__})")
574
- debug_to_log("#{strg} appears #{count} times in browser.text.")
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)
575
691
  end
576
692
 
577
693
  alias validate_link_not_enabled link_disabled?
578
694
 
695
+ # @!endgroup Legacy
696
+ # @!group Core
697
+
579
698
  def popup_exists?(popup, message=nil)
580
699
  if not message
581
700
  message = "Popup: #{popup.title}"
@@ -599,94 +718,35 @@ module Awetestlib
599
718
  alias iepopup_exists popup_exists?
600
719
  alias iepopup_exists? popup_exists?
601
720
 
602
- def validate_drag_drop(err, tol, exp, act)
603
- ary = [false, "failed, expected: #{exp}, actual: #{act}, err: #{err}"]
604
- if err == 0
605
- ary = [true, 'succeeded ']
606
- elsif err.abs <= tol
607
- ary = [true, "within tolerance (+-#{tol}px) "]
608
- end
609
- ary
610
- end
611
-
612
- def validate_list(browser, listId, text, message)
613
- message_to_log("Method validate_list() is deprecated: use validate_list_by_xxx instead")
614
- validate_list_by_id(browser, listId, text, message)
615
- end
616
-
617
721
  #Validate select list contains text
618
- def validate_list_by_id(browser, strg, text, message, select_if_present=true)
619
- #TODO Use select_list_includes?() ?
620
- if browser.select_list(:id, strg).exists?
621
- select_list = browser.select_list(:id, strg)
622
- if select_list.include?(text)
623
- if select_if_present
624
- if select_option_by_id_and_option_text(browser, strg, text)
625
- if validate(browser, @myName, __LINE__)
626
- passed_to_log(message)
627
- true
628
- end
629
- else
630
- failed_to_log(message + " (#{__LINE__})")
631
- end
632
- else
633
- if validate(browser, @myName, __LINE__)
634
- passed_to_log(message)
635
- true
636
- end
637
- end
722
+ def validate_list_by_id(browser, what, option, desc = '', select_if_present = true)
723
+ if select_list_includes?(browser, :id, what, option, desc)
724
+ if select_if_present
725
+ select_option(browser, :id, what, :text, option, desc, false)
638
726
  else
639
- failed_to_log(message + " Not found. (#{__LINE__})")
727
+ passed_to_log(message)
728
+ true
640
729
  end
641
- else
642
- failed_to_log("Select list with id='#{strg} not found. (#{__LINE__})")
643
730
  end
644
- rescue
645
- failed_to_log("Unable to validate selectlist with id='#{strg}: '#{$!}'. (#{__LINE__})")
646
731
  end
647
732
 
648
733
  #Validate select list contains text
649
- def validate_list_by_name(browser, strg, text, message, select_if_present=true)
650
- #TODO Use select_list_includes?() ?
651
- if browser.select_list(:name, strg).exists?
652
- select_list = browser.select_list(:name, strg)
653
- if select_list.include?(text)
654
- if select_if_present
655
- if select_option_by_name_and_option_text(browser, strg, text)
656
- if validate(browser, @myName, __LINE__)
657
- passed_to_log(message)
658
- true
659
- end
660
- else
661
- failed_to_log(message + " (#{__LINE__})")
662
- end
663
- else
664
- if validate(browser, @myName, __LINE__)
665
- passed_to_log(message)
666
- true
667
- end
668
- end
734
+ def validate_list_by_name(browser, what, option, desc = '', select_if_present = true)
735
+ if select_list_includes?(browser, :name, what, option, desc)
736
+ if select_if_present
737
+ select_option(browser, :name, what, :text, option, desc, false)
669
738
  else
670
- failed_to_log(message + " Not found. (#{__LINE__})")
739
+ passed_to_log(message)
740
+ true
671
741
  end
672
- else
673
- failed_to_log("Select list with name='#{strg} not found. (#{__LINE__})")
674
742
  end
675
- rescue
676
- failed_to_log("Unable to validate that '#{text}' appeared in select list with name='#{strg}: '#{$!}'. (#{__LINE__})")
677
- end
678
-
679
- #Validate select list does not contain text
680
- def validate_no_list(browser, id, text, desc = '')
681
- select_list_does_not_include?(browser, :id, id, text, desc)
682
743
  end
683
744
 
684
745
  def validate_text(browser, ptrn, desc = '', skip_fail = false, skip_sleep = false)
685
746
  cls = browser.class.to_s
686
747
  cls.gsub!('Watir::', '')
687
748
  cls.gsub!('IE', 'Browser')
688
- msg = "#{cls} text contains '#{ptrn}'."
689
- msg << " #{desc}" if desc.length > 0
749
+ msg = build_message("#{cls} text contains '#{ptrn}'.", desc)
690
750
  if ptrn.is_a?(Regexp)
691
751
  target = ptrn
692
752
  else
@@ -695,15 +755,13 @@ module Awetestlib
695
755
  sleep_for(2) unless skip_sleep
696
756
  myText = browser.text
697
757
  if not myText.match(target)
698
- sleep_for(2) unless skip_sleep #TODO try a wait_until here
758
+ sleep_for(2) unless skip_sleep #TODO try a wait_until here?
699
759
  myText = browser.text
700
760
  end
701
761
  if myText.match(target)
702
762
  #if myText.match(ptrn)
703
- if validate(browser, @myName, __LINE__)
704
- passed_to_log("#{msg}")
705
- true
706
- end
763
+ passed_to_log("#{msg}")
764
+ true
707
765
  else
708
766
  if skip_fail
709
767
  debug_to_log("#{cls} text does not contain the text: '#{ptrn}'. #{desc}")
@@ -713,11 +771,13 @@ module Awetestlib
713
771
  #debug_to_log("\n#{myText}")
714
772
  end
715
773
  rescue
716
- failed_to_log("Unable to validate #{msg} '#{$!}'")
774
+ failed_to_log("Unable to verify that #{msg} '#{$!}'")
717
775
  end
718
776
 
719
777
  alias validate_link validate_text
720
778
 
779
+ # @!group Core
780
+
721
781
  def text_in_element_equals?(browser, element, how, what, expected, desc = '')
722
782
  msg = "Expected exact text '#{expected}' in #{element} :#{how}=>#{what}."
723
783
  msg << " #{desc}" if desc.length > 0
@@ -738,10 +798,6 @@ module Awetestlib
738
798
  failed_to_log("Unable to verify #{msg} '#{$!}'")
739
799
  end
740
800
 
741
- def text_in_span_equals?(browser, how, what, expected, desc = '')
742
- text_in_element_equals?(browser, :span, how, what, expected, desc)
743
- end
744
-
745
801
  def element_contains_text?(browser, element, how, what, expected, desc = '')
746
802
  msg = "Element #{element} :{how}=>#{what} contains text '#{expected}'."
747
803
  msg << " #{desc}" if desc.length > 0
@@ -773,6 +829,23 @@ module Awetestlib
773
829
  failed_to_log("Unable to verify #{msg} '#{$!}'")
774
830
  end
775
831
 
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
+
776
849
  def span_contains_text?(browser, how, what, expected, desc = '')
777
850
  element_contains_text?(browser, :span, how, what, expected, desc)
778
851
  end
@@ -783,18 +856,9 @@ module Awetestlib
783
856
  element_contains_text?(browser, :span, :id, id, strg, desc)
784
857
  end
785
858
 
786
- def validate_url(browser, url, message = '')
787
- if browser.url.to_s.match(url)
788
- if validate(browser, @myName, __LINE__)
789
- passed_to_log('Found "'+url.to_s+'" ' + message)
790
- true
791
- end
792
- else
793
- failed_to_log('Did not find "'+url.to_s+'" ' + message + " (#{__LINE__})")
794
- end
795
- rescue
796
- failed_to_log("Unable to validate that current url is '#{url}': '#{$!}'. (#{__LINE__})")
797
- end
859
+ # @!endgroup Legacy
860
+
861
+ # @!group Core
798
862
 
799
863
  def validate_select_list(browser, how, what, opt_type, list = nil, multiple = false, ignore = ['Select One'], limit = 5)
800
864
  mark_testlevel("#{__method__.to_s.titleize} (#{how}=>#{what})", 2)
@@ -938,25 +1002,21 @@ module Awetestlib
938
1002
  end
939
1003
  browser_text = browser.text
940
1004
  if browser_text.match(target)
941
- if validate(browser, @myName, __LINE__)
942
- failed_to_log("#{msg} [#{browser_text.match(target)[0]}]")
943
- end
1005
+ failed_to_log("#{msg} [#{browser_text.match(target)[0]}]")
944
1006
  else
945
1007
  passed_to_log(msg)
946
1008
  true
947
1009
  end
948
1010
  rescue
949
- failed_to_log("Unable to validate #{msg}: '#{$!}'")
1011
+ failed_to_log("Unable to verify that #{msg}: '#{$!}'")
950
1012
  end
951
1013
 
952
1014
  def textfield_does_not_equal?(browser, how, what, expected, desc = '')
953
1015
  msg = "Text field #{how}=>#{what} does not equal '#{expected}'"
954
1016
  msg << " #{desc}" if desc.length > 0
955
1017
  if not browser.text_field(how, what).value == expected
956
- if validate(browser, @myName, __LINE__)
957
- passed_to_log(msg)
958
- true
959
- end
1018
+ passed_to_log(msg)
1019
+ true
960
1020
  else
961
1021
  failed_to_log(msg)
962
1022
  end
@@ -966,39 +1026,22 @@ module Awetestlib
966
1026
 
967
1027
  alias validate_textfield_not_value textfield_does_not_equal?
968
1028
 
969
- ###################################
1029
+ # @!endgroup Core
1030
+
1031
+ # @!group Legacy
1032
+
970
1033
  def validate_textfield_not_value_by_name(browser, name, value, desc = '')
971
1034
  textfield_does_not_equal?(browser, :name, name, value, desc)
972
1035
  end
973
1036
 
974
1037
  alias validate_textfield_no_value_by_name validate_textfield_not_value_by_name
975
1038
 
976
- ###################################
977
1039
  def validate_textfield_not_value_by_id(browser, id, value, desc = '')
978
1040
  textfield_does_not_equal?(browser, :id, id, value, desc)
979
1041
  end
980
1042
 
981
1043
  alias validate_textfield_no_value_by_id validate_textfield_not_value_by_id
982
1044
 
983
- def textfield_empty?(browser, how, what, desc = '')
984
- msg = "Text field #{how}=>#{what} is empty."
985
- msg << desc if desc.length > 0
986
- value = browser.text_field(how, what).value
987
- if value.to_s.length == 0
988
- if validate(browser, @myName, __LINE__)
989
- passed_to_log(msg)
990
- true
991
- end
992
- else
993
- failed_to_log("#{msg} Contains '#{value}'")
994
- end
995
- rescue
996
- failed_to_log("Unable to validate #{msg} '#{$!}'")
997
- end
998
-
999
- alias validate_textfield_empty textfield_empty?
1000
- alias text_field_empty? textfield_empty?
1001
-
1002
1045
  def validate_textfield_empty_by_name(browser, name, message = '')
1003
1046
  validate_textfield_empty(browser, :name, name, message)
1004
1047
  end
@@ -1011,55 +1054,6 @@ module Awetestlib
1011
1054
  validate_textfield_empty(browser, :title, title, message)
1012
1055
  end
1013
1056
 
1014
- def textfield_equals?(browser, how, what, expected, desc = '')
1015
- msg = "Expected '#{expected}' in textfield #{how}=>'#{what}'. #{desc}"
1016
- actual = browser.text_field(how, what).value
1017
- if actual.is_a?(Array)
1018
- actual = actual[0].to_s
1019
- end
1020
- #debug_to_report("#{actual.inspect}")
1021
- #debug_to_report("#{actual}")
1022
- if actual == expected
1023
- if validate(browser, @myName, __LINE__)
1024
- passed_to_log("#{msg}")
1025
- true
1026
- end
1027
- else
1028
- act_s = actual.strip
1029
- exp_s = expected.strip
1030
- if act_s == exp_s
1031
- if validate(browser, @myName, __LINE__)
1032
- passed_to_log("#{msg} (stripped)")
1033
- true
1034
- end
1035
- else
1036
- debug_to_report(
1037
- "#{__method__} (spaces underscored):\n "+
1038
- "expected:[#{expected.gsub(' ', '_')}] (#{expected.length})\n "+
1039
- "actual:[#{actual.gsub(' ', '_')}] (#{actual.length})"
1040
- )
1041
- failed_to_log("#{msg}. Found: '#{actual}'")
1042
- end
1043
- end
1044
- rescue
1045
- failed_to_log("Unable to validate #{msg}: '#{$!}")
1046
- end
1047
-
1048
- alias validate_textfield_value textfield_equals?
1049
- alias text_field_equals? textfield_equals?
1050
-
1051
- def validate_textfield_dollar_value(browser, how, what, expected, with_cents = true, desc = '')
1052
- desc << " Dollar formatting"
1053
- if with_cents
1054
- expected << '.00' if not expected =~ /\.00$/
1055
- desc << ' without cents.'
1056
- else
1057
- expected.gsub!(/\.00$/, '')
1058
- desc << ' with cents.'
1059
- end
1060
- textfield_equals?(browser, how, what, expected, desc)
1061
- end
1062
-
1063
1057
  def validate_textfield_value_by_name(browser, name, expected, desc = '')
1064
1058
  textfield_equals?(browser, :name, name, expected, desc)
1065
1059
  end
@@ -1092,48 +1086,21 @@ module Awetestlib
1092
1086
 
1093
1087
  alias visible_no_textfield_by_name validate_textfield_not_visible_by_name
1094
1088
 
1095
- def validate_radio_not_set(browser, radio, message)
1096
- if browser.radio(:id, radio).checked?
1097
- if validate(browser, @myName, __LINE__)
1098
- failed_to_log(message + " (#{__LINE__})")
1099
- end
1100
- else
1101
- passed_to_log(message)
1102
- true
1103
- end
1104
- rescue
1105
- failed_to_log("Unable to validate that radio with id='#{radio} is clear': '#{$!}'. (#{__LINE__})")
1089
+ def validate_radio_not_set(browser, what, desc = '')
1090
+ not_set?(browser, :id, what, desc)
1106
1091
  end
1107
1092
 
1108
1093
  alias validate_not_radioset validate_radio_not_set
1109
1094
 
1110
- def radio_is_set?(browser, radio, message)
1111
- if browser.radio(:id, radio).checked?
1112
- if validate(browser, @myName, __LINE__)
1113
- passed_to_log(message)
1114
- true
1115
- end
1116
- else
1117
- failed_to_log(message + " (#{__LINE__})")
1118
- end
1119
- rescue
1120
- failed_to_log("Unable to validate that radio with id='#{radio} is clear': '#{$!}'. (#{__LINE__})")
1095
+ def radio_is_set?(browser, what, desc = '')
1096
+ set?(browser, :id, what, desc)
1121
1097
  end
1122
1098
 
1123
1099
  alias validate_radioset radio_is_set?
1124
1100
  alias validate_radio_set radio_is_set?
1125
1101
 
1126
- def validate_radioset_by_name(browser, radio, message)
1127
- if browser.radio(:name, radio).checked?
1128
- if validate(browser, @myName, __LINE__)
1129
- passed_to_log(message)
1130
- true
1131
- end
1132
- else
1133
- failed_to_log(message + " (#{__LINE__})")
1134
- end
1135
- rescue
1136
- failed_to_log("Unable to validate that radio with name='#{radio} is clear': '#{$!}'. (#{__LINE__})")
1102
+ def validate_radioset_by_name(browser, what, desc = '')
1103
+ set?(browser, :name, what, desc)
1137
1104
  end
1138
1105
 
1139
1106
  def checked_by_id?(browser, strg, desc = '')
@@ -1165,19 +1132,25 @@ module Awetestlib
1165
1132
 
1166
1133
  alias validate_not_check checkbox_not_checked?
1167
1134
 
1168
- def validate_image(browser, source, desc = '', nofail=false)
1169
- if browser.image(:src, source).exists?
1170
- if validate(browser, @myName, __LINE__)
1171
- passed_to_log("Found '#{source}' image. #{desc}")
1172
- true
1173
- end
1174
- else
1175
- failed_to_log("Did not find '#{source}' image. #{desc} (#{__LINE__})") unless nofail
1176
- end
1177
- rescue
1178
- failed_to_log("Unable to validate that '#{+source}' image appeared in page: '#{$!}'. (#{__LINE__})")
1135
+ def validate_image(browser, source, desc = '', nofail = false)
1136
+ exists?(browser, :image, :src, desc)
1179
1137
  end
1180
1138
 
1139
+ # @!endgroup Legacy
1140
+
1141
+ # @!group Deprecated
1142
+ # @deprecated
1143
+ def self.included(mod)
1144
+ # puts "RegressionSupport::Validations extended by #{mod}"
1145
+ end
1146
+
1147
+ # @deprecated Use #message_to_log
1148
+ def validate_message(browser, message)
1149
+ message_to_log(message)
1150
+ end
1151
+
1152
+ # @!endgroup Deprecated
1153
+
1181
1154
  end
1182
1155
  end
1183
1156
  end