awetestlib 0.1.22-x86-mingw32 → 0.1.23-x86-mingw32

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.
@@ -2,16 +2,9 @@ module Awetestlib
2
2
  # Awetest DSL for browser based testing.
3
3
  module Regression
4
4
  # Methods covering user interactions with the browser.
5
- #
6
- #
7
- # All of the methods in groups other than Core call Core methods.
8
- # The methods in the other groups, along with aliases, exist for backward compatibility with earlier versions
9
- # of the Awetest DSL.
10
5
  module UserInput
11
6
 
12
- # @!group Core
13
-
14
- # Click a specific DOM element identified by one of its attributes and that attribute's value.
7
+ # Click a specific DOM element identified by one of its attributes (*how*) and that attribute's value (*what*).
15
8
  #
16
9
  # @example
17
10
  # # html for a link element:
@@ -31,219 +24,40 @@ module Awetestlib
31
24
  #
32
25
  def click(browser, element, how, what, desc = '')
33
26
  #debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
34
- msg = build_message("Click #{element} :#{how}=>'#{what}'", desc)
35
- msg1 = "#{element}(#{how}, '#{what}')"
36
- begin
37
- case element
38
- when :link
39
- browser.link(how, what).click
40
- when :button
41
- browser.button(how, what).click
42
- when :image
43
- browser.image(how, what).click
44
- when :radio
45
- case how
46
- when :index
47
- set_radio_by_index(browser, what, desc)
48
- else
49
- browser.radio(how, what).set
50
- end
51
- when :span
52
- browser.span(how, what).click
53
- when :div
54
- browser.div(how, what).click
55
- when :cell
56
- browser.cell(how, what).click
57
- else
58
- browser.element(how, what).click
59
- end
27
+ msg = build_message("#{__method__.to_s.humanize} :#{element} :#{how}=>'#{what}'", desc)
28
+ case element
29
+ when :link
30
+ browser.link(how, what).click
31
+ when :button
32
+ browser.button(how, what).click
33
+ when :image
34
+ browser.image(how, what).click
35
+ when :radio
36
+ case how
37
+ when :index
38
+ set_radio_by_index(browser, what, desc)
39
+ else
40
+ browser.radio(how, what).set
41
+ end
42
+ when :span
43
+ browser.span(how, what).click
44
+ when :div
45
+ browser.div(how, what).click
46
+ when :cell
47
+ browser.cell(how, what).click
48
+ else
49
+ browser.element(how, what).click
60
50
  end
61
- passed_to_log(msg)
62
- true
51
+ passed_to_log(msg)
52
+ true
63
53
  rescue
64
54
  failed_to_log("Unable to #{msg}. '#{$!}'")
65
55
  end
66
56
 
67
- # @!endgroup Core
68
-
69
- # @!group Click
70
-
71
- # Click a button element identified by the value of its *:id* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
72
- # @param [Watir::Browser, Watir::Container] browser A reference to the browser window or container element to be tested.
73
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
74
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
75
- # @return (see #click)
76
- def click_button_by_id(browser, what, desc = '')
77
- click(browser, :button, :id, what, desc)
78
- end
79
-
80
- # Click a button element identified by the value of its index within the container referred to by <b>*browser*</b>.
81
- # @param [Watir::Browser, Watir::Container] browser A reference to the browser window or container element to be tested.
82
- # @param [Fixnum] what An integer that indicates the index of the element within the container.
83
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
84
- # @return (see #click)
85
- def click_link_by_index(browser, what, desc = '')
86
- click(browser, :link, :index, what, desc)
87
- end
88
-
89
- # Click a link element identified by the value of its *:href* attribute. Take care to escape characters in the url that are reserved by Regexp.
90
- # @param (see #click_button_by_id)
91
- # @return (see #click)
92
- def click_link_by_href(browser, what, desc = '')
93
- click(browser, :link, :href, what, desc)
94
- end
95
-
96
- alias click_href click_link_by_href
97
-
98
- # Click a link element identified by the value of its *:href* attribute and do not wait for the browser to reach ready state.
99
- # Take care to escape characters in the url that are reserved by Regexp.
100
- # @param (see #click_button_by_id)
101
- # @return (see #click)
102
- def click_link_no_wait_by_href(browser, what, desc = '')
103
- click_no_wait(browser, :link, :href, what, desc)
104
- end
105
-
106
- # Click a button element identified by the value of its index within the container referred to by <b>*browser*</b>.
107
- # @param (see #click_link_by_index)
108
- # @return (see #click)
109
- def click_button_by_index(browser, what, desc = '')
110
- click(browser, :button, :index, what, desc)
111
- end
112
-
113
- # Click a button element identified by the value of its *:name* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
114
- # @param (see #click_button_by_id)
115
- # @return (see #click)
116
- def click_button_by_name(browser, what, desc = '')
117
- click(browser, :button, :name, what, desc)
118
- end
119
-
120
- # Click a button element identified by the value of its *:text* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
121
- # @param (see #click_button_by_id)
122
- # @return (see #click)
123
- def click_button_by_text(browser, what, desc = '')
124
- click(browser, :button, :text, what, desc)
125
- end
126
-
127
- # Click a button element identified by the value of its *:class* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
128
- # @param (see #click_button_by_id)
129
- # @return (see #click)
130
- def click_button_by_class(browser, what, desc = '')
131
- click(browser, :button, :class, what, desc)
132
- end
133
-
134
- # Click a button element identified by the value of its *:value* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
135
- # @param (see #click_button_by_id)
136
- # @return (see #click)
137
- def click_button_by_value(browser, what, desc = '')
138
- click(browser, :button, :value, what, desc)
139
- end
140
-
141
- # Click a button element identified by the value of its *:title* attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
142
- # @param (see #click_button_by_id)
143
- # @return (see #click)
144
- def click_button_by_title(browser, what, desc = '')
145
- click(browser, :button, :title, what, desc)
146
- end
147
-
148
- # Click a link element identified by the value of its *:id* attribute.
149
- # @param (see #click_button_by_id)
150
- # @return (see #click)
151
- def click_link_by_id(browser, what, desc = '')
152
- click(browser, :link, :id, what, desc)
153
- end
154
-
155
- alias click_id click_link_by_id
156
-
157
- # Click a link element identified by the value of its *:name* attribute.
158
- # @param (see #click_button_by_id)
159
- # @return (see #click)
160
- def click_link_by_name(browser, what, desc = '')
161
- click(browser, :link, :name, what, desc)
162
- end
163
-
164
- alias click_name click_link_by_name
165
-
166
- # Click a file_field element identified by the value of its *:id* attribute.
167
- # @param (see #click_button_by_id)
168
- # @return (see #click)
169
- def click_file_field_by_id(browser, what, desc = '')
170
- click(browser, :file_field, :id, what, desc)
171
- end
172
-
173
- # Click an image element identified by the value of its *:id* attribute.
174
- # @param (see #click_button_by_id)
175
- # @return (see #click)
176
- def click_img_by_alt(browser, what, desc = '')
177
- click(browser, :image, :alt, what, desc)
178
- end
179
-
180
- # Click an image element identified by the value of its *:title* attribute.
181
- # @param (see #click_button_by_id)
182
- # @return (see #click)
183
- def click_img_by_title(browser, what, desc = '')
184
- click(browser, :image, :title, what, desc)
185
- end
186
-
187
- # Click an image element identified by the value of its *:src* attribute.
188
- # Take care to escape characters in the source url that are reserved by Regexp.
189
- # @param (see #click_button_by_id)
190
- # @return (see #click)
191
- def click_img_by_src(browser, what, desc = '')
192
- click(browser, :image, :src, what, desc)
193
- end
194
-
195
- # Click a link element identified by the value of its *:value* attribute.
196
- # @param (see #click_button_by_id)
197
- # @return (see #click)
198
- def click_link_by_value(browser, what, desc = '')
199
- click(browser, :link, :value, what, desc)
200
- end
201
-
202
- # Click a link element identified by the value in its text (innerHTML).
203
- # @param (see #click_button_by_id)
204
- # @return (see #click)
205
- def click_link_by_text(browser, what, desc = '')
206
- click(browser, :link, :text, what, desc)
207
- end
208
-
209
- alias click_link click_link_by_text
210
- alias click_text click_link_by_text
211
- alias click_js_button click_link_by_text
212
-
213
- # Click a link element identified by the value of its *:class* attribute.
214
- # @param (see #click_button_by_id)
215
- # @return (see #click)
216
- def click_link_by_class(browser, what, desc = '')
217
- click(browser, :link, :class, what, desc)
218
- end
219
-
220
- alias click_class click_link_by_class
221
-
222
- # Click a span element identified by the value in its text (innerHTML).
223
- # @param (see #click_button_by_id)
224
- # @return (see #click)
225
- def click_span_by_text(browser, what, desc = '')
226
- click(browser, :span, :text, what)
227
- end
228
-
229
- alias click_span_with_text click_span_by_text
230
-
231
- # Click a link element identified by the value of its *:title* attribute.
232
- # @param (see #click_button_by_id)
233
- # @return (see #click)
234
- def click_link_by_title(browser, what, desc = '')
235
- click(browser, :link, :title, what, desc)
236
- end
237
-
238
- alias click_title click_link_by_title
239
-
240
- # @!endgroup Click
241
-
242
- # @!group Core
243
-
244
- # Click a specific DOM element by one of its attributes and that attribute's value and
57
+ # Click a specific DOM element by one of its attributes (*how) and that attribute's value (*what) and
245
58
  # do not wait for the browser to finish reloading. Used when a modal popup or alert is expected. Allows the script
246
59
  # to keep running so the popup can be handled.
60
+ # @todo handle using Watir Webdriver which does not need no_wait.
247
61
  #
248
62
  # @example
249
63
  # # html for a link element:
@@ -257,9 +71,7 @@ module Awetestlib
257
71
  # @return (see #click)
258
72
  #
259
73
  def click_no_wait(browser, element, how, what, desc = '')
260
- debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
261
- msg = build_message("Click no wait #{element} :#{how}=>'#{what}'", desc)
262
- msg1 = "#{element}(#{how}, '#{what}'"
74
+ msg = build_message("#{__method__.to_s.humanize} :#{element} :#{how}=>'#{what}'", desc)
263
75
  begin
264
76
  case element
265
77
  when :link
@@ -287,161 +99,17 @@ module Awetestlib
287
99
  browser.element(how, what).click_no_wait
288
100
  end
289
101
  rescue => e
290
- if not rescue_me(e, __method__, "browser(#{msg1}').click_no_wait", "#{browser.class}")
102
+ unless rescue_me(e, __method__, rescue_me_command(element, how, what, :click_no_wait), "#{browser.class}")
291
103
  raise e
292
104
  end
293
105
  end
294
- passed_to_log(msg)
295
- true
106
+ passed_to_log(msg)
107
+ true
296
108
  rescue
297
109
  failed_to_log("Unable to #{msg} '#{$!}'")
298
110
  sleep_for(1)
299
111
  end
300
112
 
301
- # @!endgroup Core
302
-
303
- alias click_href_no_wait click_link_no_wait_by_href
304
-
305
- # @!group Click No Wait
306
-
307
- # Click a button element identified by the value of its *:id* attribute
308
- # and do not wait for the browser to reach ready state.
309
- # @param (see #click_button_by_id)
310
- # @return (see #click)
311
- def click_button_no_wait_by_id(browser, what, desc = '')
312
- click_no_wait(browser, :button, :id, what, desc)
313
- end
314
-
315
- alias click_button_by_id_no_wait click_button_no_wait_by_id
316
-
317
- # Click a button element identified by the value of its *:name* attribute
318
- # and do not wait for the browser to reach ready state.
319
- # @param (see #click_button_by_id)
320
- # @return (see #click)
321
- def click_button_no_wait_by_name(browser, what, desc = '')
322
- click_no_wait(browser, :button, :name, what, desc)
323
- end
324
-
325
- # Click a button element identified by the value of its *:class* attribute
326
- # and do not wait for the browser to reach ready state.
327
- # @param (see #click_button_by_id)
328
- # @return (see #click)
329
- def click_button_no_wait_by_class(browser, what, desc = '')
330
- click_no_wait(browser, :button, :class, what, desc)
331
- end
332
-
333
- alias click_button_by_class_no_wait click_button_no_wait_by_class
334
-
335
- # Click a link element identified by the value of its *:id* attribute
336
- # and do not wait for the browser to reach ready state.
337
- # @param (see #click_button_by_id)
338
- # @return (see #click)
339
- def click_link_no_wait_by_id(browser, what, desc = '')
340
- click_no_wait(browser, :link, :id, what, desc)
341
- end
342
-
343
- alias click_no_wait_id click_link_no_wait_by_id
344
- alias click_no_wait_by_id click_link_no_wait_by_id
345
- alias click_id_no_wait click_link_no_wait_by_id
346
- alias click_no_wait_link_by_id click_link_no_wait_by_id
347
-
348
- # Click an image element identified by the value of its *:alt* attribute
349
- # and do not wait for the browser to reach ready state.
350
- # @param (see #click_button_by_id)
351
- # @return (see #click)
352
- def click_img_no_wait_by_alt(browser, what, desc = '')
353
- click_no_wait(browser, :image, :alt, what, desc)
354
- end
355
-
356
- alias click_img_by_alt_no_wait click_img_no_wait_by_alt
357
-
358
- # Click a button element identified by the value in its text (innerHTML)
359
- # and do not wait for the browser to reach ready state.
360
- # @param (see #click_button_by_id)
361
- # @return (see #click)
362
- def click_button_no_wait_by_text(browser, what, desc = '')
363
- click_no_wait(browser, :button, :text, what, desc)
364
- end
365
-
366
- # Click a button element identified by the value of its *:value* attribute
367
- # and do not wait for the browser to reach ready state.
368
- # @param (see #click_button_by_id)
369
- # @return (see #click)
370
- def click_button_no_wait_by_value(browser, what, desc = '')
371
- click_no_wait(browser, :button, :value, what, desc)
372
- end
373
-
374
- # Click a button element identified by the value of its *:name* attribute
375
- # and do not wait for the browser to reach ready state.
376
- # @param (see #click_button_by_id)
377
- # @return (see #click)
378
- def click_link_by_name_no_wait(browser, what, desc = '')
379
- click_no_wait(browser, :link, :name, what, desc)
380
- end
381
-
382
- alias click_no_wait_name click_link_by_name_no_wait
383
- alias click_name_no_wait click_link_by_name_no_wait
384
-
385
- # Click a link element identified by the value in its text (innerHTML)
386
- # and do not wait for the browser to reach ready state.
387
- # @param (see #click_button_by_id)
388
- # @return (see #click)
389
- def click_link_by_text_no_wait(browser, what, desc = '')
390
- click_no_wait(browser, :link, :text, what, desc)
391
- end
392
-
393
- alias click_no_wait_text click_link_by_text_no_wait
394
- alias click_text_no_wait click_link_by_text_no_wait
395
-
396
- # Click a link element identified by the value of its *:title* attribute
397
- # and do not wait for the browser to reach ready state.
398
- # @param (see #click_button_by_id)
399
- # @return (see #click)
400
- def click_title_no_wait(browser, what, desc = '')
401
- click_no_wait(browser, :link, :title, what, desc)
402
- end
403
-
404
- # @!endgroup Click No Wait
405
-
406
- # @!group Xpath
407
-
408
- # Click a button element identified by the value of its *:id* attribute using the xpath functionality in Watir.
409
- # A button is an HTML element with tag 'input' and type 'submit' or 'button'.
410
- # @note Normally used only when the element is not located by other methods.
411
- # @param (see #click_button_by_id)
412
- # @return (see #click)
413
- def click_button_by_xpath_and_id(browser, what, desc = '')
414
- click(browser, :button, :xpath, "//a[@id = '#{what}']", desc)
415
- end
416
-
417
- alias click_button_by_xpath click_button_by_xpath_and_id
418
-
419
- # Click a link element identified by the value of its *:id* attribute using the xpath functionality in Watir.
420
- # @note Normally used only when the element is not located by other methods.
421
- # @param (see #click_button_by_id)
422
- # @return (see #click)
423
- def click_link_by_xpath_and_id(browser, what, desc = '')
424
- click(browser, :link, :xpath, "//a[@id = '#{what}']", desc)
425
- end
426
-
427
- alias click_link_by_xpath click_link_by_xpath_and_id
428
-
429
- # Click an image element identified by the value of its *:name* attribute using the xpath functionality in Watir.
430
- # @note Normally used only when the element is not located by other methods.
431
- # @param (see #click_button_by_id)
432
- # @return (see #click)
433
- def click_img_by_xpath_and_name(browser, what, desc = '')
434
- click(browser, :image, :xpath, "//a[@id = '#{what}']", desc)
435
- end
436
-
437
- alias click_img_by_xpath click_img_by_xpath_and_name
438
- alias click_image_by_xpath click_img_by_xpath_and_name
439
- alias click_image_by_xpath_and_name click_img_by_xpath_and_name
440
-
441
- # @!endgroup Xpath
442
-
443
- # @!group Core
444
-
445
113
  # Click an image element identified by the value of its *:src* attribute and its index
446
114
  # within the array of image elements with src containing <b>*what*</b> and
447
115
  # within the container referred to by <b>*browser*</b>.
@@ -454,8 +122,8 @@ module Awetestlib
454
122
  msg = "Click image by src='#{what}' and index=#{index}"
455
123
  msg << " #{desc}" if desc.length > 0
456
124
  browser.image(:src => what, :index => index).click
457
- passed_to_log(msg)
458
- true
125
+ passed_to_log(msg)
126
+ true
459
127
  rescue
460
128
  failed_to_log("Unable to #{msg} '#{$!}'")
461
129
  end
@@ -474,14 +142,14 @@ module Awetestlib
474
142
  # @return (see #click)
475
143
  #
476
144
  def click_table_row_with_text(browser, how, what, text, desc = '', column = nil)
477
- msg = build_message("Click row with text #{text} in table :#{how}=>'#{what}.", desc)
145
+ msg = build_message("Click row with text #{text} in table :#{how}=>'#{what}.", desc)
478
146
  table = get_table(browser, how, what, desc)
479
147
  if table
480
148
  index = get_index_of_row_with_text(table, text, column)
481
149
  if index
482
150
  table[index].click
483
- passed_to_log(msg)
484
- index
151
+ passed_to_log(msg)
152
+ index
485
153
  else
486
154
  failed_to_log("#{msg} Row not found.")
487
155
  end
@@ -499,14 +167,14 @@ module Awetestlib
499
167
  # @return (see #click)
500
168
  #
501
169
  def double_click_table_row_with_text(browser, how, what, text, desc = '', column = nil)
502
- msg = build_message("Double click row with text #{text} in table :#{how}=>'#{what}.", desc)
170
+ msg = build_message("Double click row with text #{text} in table :#{how}=>'#{what}.", desc)
503
171
  table = get_table(browser, how, what, desc)
504
172
  if table
505
173
  index = get_index_of_row_with_text(table, text, column)
506
174
  if index
507
175
  table[index].fire_event('ondblclick')
508
- passed_to_log(msg)
509
- index
176
+ passed_to_log(msg)
177
+ index
510
178
  else
511
179
  failed_to_log("#{msg} Row not found.")
512
180
  end
@@ -517,59 +185,6 @@ module Awetestlib
517
185
  failed_to_log("Unable to #{msg}: '#{$!}'")
518
186
  end
519
187
 
520
- # @!endgroup Core
521
-
522
- # @!group Tables
523
-
524
- # Click the first row which contains a particular string in a table identified by the value in its *:id* attribute.
525
- #
526
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
527
- # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
528
- # @param [String] text Full text string to be found in the table row.
529
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
530
- # @param [Fixnum] column Integer indicating the column to search for the text string.
531
- # If not supplied all columns will be checked.
532
- # @return (see #click)
533
- #
534
- def click_table_row_with_text_by_id(browser, what, text, desc = '', column = nil)
535
- click_table_row_with_text(browser, :id, what, text, desc, column)
536
- end
537
-
538
- # Click the first row which contains a particular string in a table identified by its index
539
- # in the array of tables contained in <b>*browser*</b>.
540
- # A specific column in the table can also be specified.
541
- #
542
- # @param (see #click_table_row_with_text_by_id)
543
- # @return (see #click)
544
- #
545
- def click_table_row_with_text_by_index(browser, what, text, desc = '', column = nil)
546
- click_table_row_with_text(browser, :id, what, text, desc, column)
547
- end
548
-
549
- # Double click the first row which contains a particular string in a table identified by the value in its *:id* attribute.
550
- # A specific column in the table can also be specified.
551
- #
552
- # @param (see #click_table_row_with_text_by_id)
553
- # @return (see #click)
554
- #
555
- def double_click_table_row_with_text_by_id(browser, what, text, desc = '', column = nil)
556
- double_click_table_row_with_text(browser, :id, what, text, desc, column)
557
- end
558
-
559
- # Double click the first row which contains a particular string in a table identified by its index
560
- # in the array of tables contained in <b>*browser*</b>.
561
- # A specific column in the table can also be specified.
562
- # @param (see #click_table_row_with_text_by_id)
563
- # @return (see #click)
564
- #
565
- def double_click_table_row_with_text_by_index(browser, idx, what, column = nil)
566
- double_click_table_row_with_text(browser, :index, what, text, desc, column)
567
- end
568
-
569
- # @!endgroup Tables
570
-
571
- # @!group Core
572
-
573
188
  # Click a specifific button on a popup window.
574
189
  # (Windows only)
575
190
  # @param [String] title A string starting at the beginning of the title which uniquely identifies the popup window.
@@ -611,7 +226,7 @@ module Awetestlib
611
226
  # @param [Boolean] nofail If true do not log a failed message if the option is not found in the select list.
612
227
  # @return (see #click)
613
228
  def select_option_from_list(list, how, what, desc = '', nofail = false)
614
- msg = build_message("Select :#{how}=>'#{what}", desc)
229
+ msg = build_message("Select :#{how}=>'#{what}'", desc)
615
230
  ok = true
616
231
  if list
617
232
  case how
@@ -656,97 +271,10 @@ module Awetestlib
656
271
  # @return (see #click)
657
272
  def select_option(browser, how, what, which, option, desc = '', nofail = false)
658
273
  list = browser.select_list(how, what)
659
- msg = build_message(" from list with :#{how}=>'#{what}", desc)
274
+ msg = build_message("from list with :#{how}=>'#{what}", desc)
660
275
  select_option_from_list(list, which, option, msg, nofail)
661
276
  end
662
277
 
663
- # @!endgroup Core
664
-
665
- # @!group Select
666
-
667
- # Select option from select list (dropdown) identified by the value in its *:id* attribute. Option is identified by *which* and *value*
668
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
669
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
670
- # @param [String/Rexexp] option A string or regular expression that will uniquely identify the option to select.
671
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
672
- # @param [Boolean] nofail If true do not log a failed message if the option is not found in the select list.
673
- # @return (see #click)
674
- def select_option_by_id_and_option_text(browser, what, option, nofail = false, desc = '')
675
- select_option(browser, :id, what, :text, option, desc, nofail)
676
- end
677
-
678
- alias select_option_by_id select_option_by_id_and_option_text
679
- alias select_option_by_id_and_text select_option_by_id_and_option_text
680
-
681
- # Select option from select list (dropdown) identified by the value in its *:name* attribute. Option is selected by its *:text* attribute.
682
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
683
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
684
- # @param [String/Rexexp] option A string or regular expression that will uniquely identify the option to select.
685
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
686
- # @return (see #click)
687
- def select_option_by_name_and_option_text(browser, what, option, desc = '')
688
- select_option(browser, :name, what, :text, option, desc)
689
- end
690
-
691
- alias select_option_by_name select_option_by_name_and_option_text
692
-
693
- # Select option from select list (dropdown) identified by the value in its *:name* attribute. Option is selected by its *:text* attribute.
694
- # @param (see #select_option_by_name_and_option_text)
695
- # @return (see #click)
696
- def select_option_by_title_and_option_text(browser, what, option, desc = '')
697
- select_option(browser, :title, what, :text, option, desc)
698
- end
699
-
700
- # Select option from select list (dropdown) identified by the value in its *:class* attribute. Option is selected by its *:text* attribute.
701
- # @param (see #select_option_by_name_and_option_text)
702
- # @return (see #click)
703
- def select_option_by_class_and_option_text(browser, what, option, desc = '')
704
- select_option(browser, :class, what, :text, option, desc)
705
- end
706
-
707
- # Select option from select list (dropdown) identified by the value in its *:name* attribute. Option is selected by its *:value* attribute.
708
- # @param (see #select_option_by_name_and_option_text)
709
- # @return (see #click)
710
- def select_option_by_name_and_option_value(browser, what, option, desc = '')
711
- select_option(browser, :name, what, :value, option, desc)
712
- end
713
-
714
- # Select option from select list (dropdown) identified by the value in its *:id* attribute. Option is selected by its *:value* attribute.
715
- # @param (see #select_option_by_name_and_option_text)
716
- # @return (see #click)
717
- def select_option_by_id_and_option_value(browser, what, option, desc = '')
718
- select_option(browser, :id, what, :value, option, desc)
719
- end
720
-
721
- # Select option from select list (dropdown) identified by the value in its *:id* attribute.
722
- # Option is selected by its index withing the select list's array of options.
723
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
724
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
725
- # @param [Fixnum] index An integer that indicates the index of the element within the array of options.
726
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
727
- # @return (see #click)
728
- def select_option_by_id_and_index(browser, what, index, desc = '')
729
- select_option(browser, :id, what, :index, index, desc)
730
- end
731
-
732
- # Select option from select list (dropdown) identified by the value in its *:name* attribute. Option is selected by its *:index* attribute.
733
- # @param (see #select_option_by_id_and_index)
734
- # @return (see #click)
735
- def select_option_by_name_and_index(browser, what, option, desc = '')
736
- select_option(browser, :name, what, :index, option, desc)
737
- end
738
-
739
- # Select option from select list (dropdown) identified by the xpath command supplied in *what*. Option is selected by its *:index* attribute.
740
- # @param (see #select_option_by_id_and_index)
741
- # @return (see #click)
742
- def select_option_by_xpath_and_index(browser, what, option, desc = '')
743
- select_option(browser, :xpath, what, :index, option, desc)
744
- end
745
-
746
- # @!endgroup Select
747
-
748
- # @!group Core
749
-
750
278
  # Set radio button or checkbox to selected.
751
279
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
752
280
  # @param [Symbol] element The kind of element to click. Must be either :radio or :checkbox.
@@ -769,13 +297,13 @@ module Awetestlib
769
297
  else
770
298
  failed_to_log("#{__method__}: #{element} not supported")
771
299
  end
772
- passed_to_log(msg)
773
- true
300
+ passed_to_log(msg)
301
+ true
774
302
  rescue
775
- failed_to_log("#{msg} '#{$!}'")
776
- end
303
+ failed_to_log("#{msg} '#{$!}'")
304
+ end
777
305
 
778
- # Set file field element, identified by *how* and +what, to a specified file path and name.
306
+ # Set file field element, identified by *how* and *what*, to a specified file path and name.
779
307
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
780
308
  # @param [Symbol] how The element attribute used to identify the specific element.
781
309
  # Valid values depend on the kind of element.
@@ -785,13 +313,13 @@ module Awetestlib
785
313
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
786
314
  # @return (see #click)
787
315
  def set_file_field(browser, how, what, filespec, desc = '')
788
- msg = build_message("Set file field #{how}=>#{what} to '#{filespec}.", desc)
789
- ff = browser.file_field(how, what)
316
+ msg = build_message("#{__method__.to_s.humanize} #{how}=>#{what} to '#{filespec}.", desc)
317
+ ff = browser.file_field(how, what)
790
318
  if ff
791
319
  ff.set filespec
792
320
  sleep_for(8)
793
- passed_to_log(msg)
794
- true
321
+ passed_to_log(msg)
322
+ true
795
323
  else
796
324
  failed_to_log("#{msg} File field not found.")
797
325
  end
@@ -812,8 +340,8 @@ module Awetestlib
812
340
  def set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '')
813
341
  msg = build_message("Set radio #{how1}='#{what1}', #{how2}= #{what2}", desc)
814
342
  browser.radio(how1 => what1, how2 => what2).set
815
- passed_to_log(msg)
816
- true
343
+ passed_to_log(msg)
344
+ true
817
345
  rescue
818
346
  failed_to_log("#{msg} '#{$!}'")
819
347
  end
@@ -834,188 +362,6 @@ module Awetestlib
834
362
  # failed_to_log("#{msg} (#{__LINE__})")
835
363
  #end
836
364
 
837
- # @!endgroup Core
838
-
839
- # @!group Set
840
-
841
- # Set checkbox as checked. Checkbox is identified by the attribute specified in *how* with value *what*. It's *:value* attribute can also be used
842
- # when needed by specifying *value*.
843
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
844
- # @param [Symbol] how The element attribute used to identify the specific checkbox.
845
- # Valid values depend on the kind of element.
846
- # Common values: :text, :id, :title, :name, :class, :href (:link only)
847
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the checkbox.
848
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute of the checkbox.
849
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
850
- # @return (see #click)
851
- def set_checkbox(browser, how, what, value = nil, desc = '')
852
- set(browser, :checkbox, how, what, value, desc)
853
- end
854
-
855
- # Set checkbox as checked identified by its *:class* attribute with the value in *what*. It's *:value* attribute can also be used
856
- # when needed by specifying *value*.
857
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
858
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the checkbox.
859
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute of the checkbox.
860
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
861
- # @return (see #click)
862
- def set_checkbox_by_class(browser, what, value = nil, desc = '')
863
- set(browser, :checkbox, :class, what, value, desc)
864
- end
865
-
866
- # Set checkbox as checked identified by its *:class* attribute with the value in *what*. It's *:value* attribute can also be used
867
- # when needed by specifying *value*.
868
- # @param (see #set_checkbox_by_class)
869
- # @return (see #click)
870
- def set_checkbox_by_id(browser, what, value = nil, desc = '')
871
- set(browser, :checkbox, :id, what, value, desc)
872
- end
873
-
874
- # Set checkbox as checked identified by its *:name* attribute with the value in *what*. It's *:value* attribute can also be used
875
- # when needed by specifying *value*.
876
- # @param (see #set_checkbox_by_class)
877
- # @return (see #click)
878
- def set_checkbox_by_name(browser, what, value = nil, desc = '')
879
- set(browser, :checkbox, :name, what, value, desc)
880
- end
881
-
882
- # Set checkbox as checked identified by its *:title* attribute with the value in *what*. It's *:value* attribute can also be used
883
- # when needed by specifying *value*.
884
- # @param (see #set_checkbox_by_class)
885
- # @return (see #click)
886
- def set_checkbox_by_title(browser, what, value = nil, desc = '')
887
- set(browser, :checkbox, :title, what, value, desc)
888
- end
889
-
890
- # Set checkbox as checked identified by its *:value* attribute with the value in *what*.
891
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
892
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the checkbox.
893
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
894
- # @return (see #click)
895
- def set_checkbox_by_value(browser, what, desc = '')
896
- set(browser, :checkbox, :value, what, nil, desc)
897
- end
898
-
899
- # Set radio button as set. Radio is identified by the attribute specified in *how* with value *what*. It's *:value* attribute can also be used
900
- # when needed by specifying *value*.
901
- # @param (see #set_checkbox)
902
- # @return (see #click)
903
- def set_radio(browser, how, what, value = nil, desc = '')
904
- set(browser, :radio, how, what, value, desc)
905
- end
906
-
907
- # Set radio button as set identified by its *:class* attribute with the value in *what*. It's *:value* attribute can also be used
908
- # when needed by specifying *value*.
909
- # @param (see #set_checkbox_by_class)
910
- def set_radio_by_class(browser, what, value = nil, desc = '')
911
- set(browser, :radio, :class, what, value, desc)
912
- end
913
-
914
- # Set radio button as set identified by its *:id* attribute with the value in *what*. It's *:value* attribute can also be used
915
- # when needed by specifying *value*.
916
- # @param (see #set_checkbox_by_class)
917
- # @return (see #click)
918
- def set_radio_by_id(browser, what, value = nil, desc = '')
919
- set(browser, :radio, :id, what, value, desc)
920
- end
921
-
922
- # Set radio button as set identified by its index within the array of radio buttons found in the container specified by *browser*.
923
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
924
- # @param [Fixnum] index An integer that indicates the index of the element within *browser*.
925
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
926
- # @return (see #click)
927
- def set_radio_by_index(browser, index, desc = '')
928
- set(browser, :radio, :index, index, nil, desc)
929
- end
930
-
931
- # Set radio button as set identified by its *:name* attribute with the value in *what*. It's *:value* attribute can also be used
932
- # when needed by specifying *value*.
933
- # @param (see #set_checkbox_by_class)
934
- # @return (see #click)
935
- def set_radio_by_name(browser, what, value = nil, desc = '')
936
- set(browser, :radio, :name, what, value, desc)
937
- end
938
-
939
- # Set radio button as set identified by its *:title* attribute with the value in *what*. It's *:value* attribute can also be used
940
- # when needed by specifying *value*.
941
- # @param (see #set_checkbox_by_class)
942
- # @return (see #click)
943
- def set_radio_by_title(browser, what, value = nil, desc = '')
944
- set(browser, :radio, :title, what, value, desc)
945
- end
946
-
947
- # Set radio button as set identified by its *:value* attribute with the value in *what*.
948
- # @param (see #set_checkbox_by_value)
949
- # @return (see #click)
950
- def set_radio_by_value(browser, what, desc = '')
951
- set(browser, :radio, :value, what, nil, desc)
952
- end
953
-
954
- # Set radio button as set identified by its *:name* attribute with the value in *what*
955
- # and its index within the array of radio buttons with that :name
956
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
957
- # @param [String, Regexp] what A string or a regular expression to be found in the *:name* attribute that identifies the group of radio buttons.
958
- # @param [Fixnum] index An integer that indicates the index of the radio button to be set.
959
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
960
- # @return (see #click)
961
- def set_radio_by_name_and_index(browser, what, index, desc = '')
962
- set_radio_two_attributes(browser, :name, what, :index, index, desc)
963
- end
964
-
965
- # Set radio button as set identified by its *:name* attribute with the value in *what*
966
- # and its index within the array of radio buttons with that :name
967
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
968
- # @param [String, Regexp] what A string or a regular expression to be found in the *:name* attribute that identifies the group of radio buttons.
969
- # @param [String, Regexp] text A string or a regular expression to be found in the *:text* attribute that uniquely identifies the the radio button to be set.
970
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
971
- # @return (see #click)
972
- def set_radio_by_name_and_text(browser, what, text, desc = '')
973
- set_radio_two_attributes(browser, :name, what, :text, text, desc)
974
- end
975
-
976
- # Set radio button as set identified by its *:value* attribute with the value in *what*
977
- # and its index within the array of radio buttons with that :name
978
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
979
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute that identifies the group of radio buttons.
980
- # @param [Fixnum] index An integer that indicates the index of the radio button to be set.
981
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
982
- # @return (see #click)
983
- def set_radio_by_value_and_index(browser, value, index, desc = '')
984
- set_radio_two_attributes(browser, :value, value, :index, index, desc)
985
- end
986
-
987
- # Set radio button as set identified by its *:name* attribute with the value in *what*
988
- # and the *:value* attribute with the value in *value*.
989
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
990
- # @param [String, Regexp] what A string or a regular expression to be found in the *:name* attribute that identifies the group of radio buttons.
991
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute that uniquely identifies the the radio button to be set.
992
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
993
- # @return (see #click)
994
- def set_radio_by_name_and_value(browser, what, value, desc = '')
995
- set_radio(browser, :name, what, value, desc)
996
- end
997
-
998
- # Set file field element, identified by its *:name* attribute with the value in *what*.
999
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1000
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
1001
- # @param [String] filespec The full path and name of the target file.
1002
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
1003
- # @return (see #click)
1004
- def set_file_field_by_name(browser, what, filespec, desc = '')
1005
- set_file_field(browser, :name, what, filespec, desc)
1006
- end
1007
-
1008
- # Set file field element, identified by its *:id* attribute with the value in *what*.
1009
- # @param (see #set_file_field_by_name)
1010
- # @return (see #click)
1011
- def set_file_field_by_id(browser, what, filespec, desc = '')
1012
- set_file_field(browser, :id, what, filespec, desc)
1013
- end
1014
-
1015
- # @!endgroup Set
1016
-
1017
- # @!group Core
1018
-
1019
365
  # Clear (unset) radio, checkbox or text field as identified by the attribute specified in *how* with value *what*.
1020
366
  # It's *:value* attribute can also be used when needed by specifying *value* (Ignored for text_field).
1021
367
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
@@ -1042,68 +388,12 @@ module Awetestlib
1042
388
  else
1043
389
  failed_to_log("#{__method__}: #{element} not supported")
1044
390
  end
1045
- passed_to_log(msg)
1046
- true
391
+ passed_to_log(msg)
392
+ true
1047
393
  rescue
1048
394
  failed_to_log("#{msg} '#{$!}'")
1049
395
  end
1050
396
 
1051
- # @!endgroup Core
1052
-
1053
- # @!group Clear
1054
-
1055
- # Clear (uncheck) checkbox identified by the attribute specified in *how* with value *what*.
1056
- # It's *:value* attribute can also be used when needed by specifying *value*.
1057
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1058
- # @param [Symbol] how The element attribute used to identify the specific checkbox.
1059
- # Valid values depend on the kind of element.
1060
- # Common values: :text, :id, :title, :name, :class.
1061
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
1062
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute of the element.
1063
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
1064
- # @return (see #click)
1065
- def clear_checkbox(browser, how, what, value = nil, desc = '')
1066
- clear(browser, :checkbox, how, what, value, desc)
1067
- end
1068
-
1069
- # Clear (uncheck) checkbox identified by its *:name* attribute with value *what*.
1070
- # It's *:value* attribute can also be used when needed by specifying *value*.
1071
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1072
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
1073
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute of the element.
1074
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
1075
- # @return (see #click)
1076
- def clear_checkbox_by_name(browser, what, value = nil, desc = '')
1077
- clear(browser, :checkbox, :name, what, value, desc)
1078
- end
1079
-
1080
- # Clear (uncheck) checkbox identified by its *:id* attribute with value *what*.
1081
- # It's *:value* attribute can also be used when needed by specifying *value*.
1082
- # @param (see #set_file_field_by_name)
1083
- # @return (see #click)
1084
- def clear_checkbox_by_name(browser, what, value = nil, desc = '')
1085
- clear(browser, :checkbox, :id, what, value, desc)
1086
- end
1087
-
1088
- # Clear (unset) radio button identified by the attribute specified in *how* with value *what*.
1089
- # It's *:value* attribute can also be used when needed by specifying *value*.
1090
- # This clears the specified radio without setting any other radio buttons on.
1091
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1092
- # @param [Symbol] how The element attribute used to identify the specific checkbox.
1093
- # Valid values depend on the kind of element.
1094
- # Common values: :text, :id, :title, :name, :class.
1095
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
1096
- # @param [String, Regexp] value A string or a regular expression to be found in the *:value* attribute of the element.
1097
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
1098
- # @return (see #click)
1099
- def clear_radio(browser, how, what, value = nil, desc = '')
1100
- clear(browser, :radio, how, what, value, desc)
1101
- end
1102
-
1103
- # @!endgroup Clear
1104
-
1105
- # @!group Core
1106
-
1107
397
  # Set text field as identified by the attribute specified in *how* with value in *what* to the string specified in *value*.
1108
398
  # This method differs from set() in that it validates that the text field has been set to the specified value.
1109
399
  # The value verification can be turned off by setting *skip_value_check* to true.
@@ -1119,23 +409,24 @@ module Awetestlib
1119
409
  # @return (see #click)
1120
410
  def set_text_field(browser, how, what, value, desc = '', skip_value_check = false)
1121
411
  #TODO: fix this to handle Safari password field
1122
- msg = build_message("Set textfield #{how}='#{what}' to '#{value}'", desc)
412
+ msg = build_message("#{__method__.to_s.humanize} #{how}='#{what}' to '#{value}'", desc)
1123
413
  msg << " (Skip value check)" if skip_value_check
1124
414
  if browser.text_field(how, what).exists?
1125
415
  tf = browser.text_field(how, what)
1126
- #debug_to_log("#{tf.inspect}")
1127
- tf.set(value)
1128
- if tf.value == value
1129
- passed_to_log(msg)
1130
- true
1131
- elsif skip_value_check
1132
- passed_to_log(msg)
1133
- true
1134
- else
1135
- failed_to_log("#{msg}: Found:'#{tf.value}'.")
1136
- end
416
+ tf.set(value)
417
+ if skip_value_check
418
+ passed_to_log(msg)
419
+ true
420
+ else
421
+ if tf.value == value
422
+ passed_to_log(msg)
423
+ true
424
+ else
425
+ failed_to_log("#{msg}: Found:'#{tf.value}'.")
426
+ end
427
+ end
1137
428
  else
1138
- failed_to_log("#{msg}: Textfield #{how}='#{what}' not found")
429
+ failed_to_log("#{msg}: Textfield not found")
1139
430
  end
1140
431
  rescue
1141
432
  failed_to_log("Unable to '#{msg}': '#{$!}'")
@@ -1156,23 +447,25 @@ module Awetestlib
1156
447
  # @param [Boolean] skip_value_check Forces verification of value in text field to pass.
1157
448
  # @return (see #click)
1158
449
  def clear_textfield(browser, how, what, skip_value_check = false)
450
+ msg1 = "Skip value check." if skip_value_check
451
+ msg = build_message("#{__method__.to_s.humanize} #{how}='#{what}'.", msg1)
1159
452
  if browser.text_field(how, what).exists?
1160
453
  tf = browser.text_field(how, what)
1161
- tf.clear
1162
- if tf.value == ''
1163
- passed_to_log("Textfield #{how}='#{what}' cleared.")
1164
- true
1165
- elsif skip_value_check
1166
- passed_to_log("Textfield #{how}='#{what}' cleared. (skip value check)")
1167
- true
1168
- else
1169
- failed_to_log("Textfield #{how}='#{what}' not cleared: Found:'#{tf.value}'. (#{__LINE__})")
1170
- end
454
+ tf.clear
455
+ if tf.value == ''
456
+ passed_to_log(msg)
457
+ true
458
+ elsif skip_value_check
459
+ passed_to_log(msg)
460
+ true
461
+ else
462
+ failed_to_log("#{msg} Found:'#{tf.value}'.")
463
+ end
1171
464
  else
1172
- failed_to_log("Textfield id='#{id}' to clear. (#{__LINE__})")
465
+ failed_to_log("#{msg} Textfield not found.")
1173
466
  end
1174
467
  rescue
1175
- failed_to_log("Textfield id='#{id}' could not be cleared: '#{$!}'. (#{__LINE__})")
468
+ failed_to_log("Unable to #{msg} '#{$!}'.")
1176
469
  end
1177
470
 
1178
471
  #Enter a string into a text field element identified by an attribute type and a value.
@@ -1198,7 +491,7 @@ module Awetestlib
1198
491
  #NOTE: use when value and valid_value differ as with dollar reformatting
1199
492
  if set_text_field(browser, how, what, value, desc, true)
1200
493
  expected = valid_value ? valid_value : value
1201
- validate_textfield_value(browser, how, what, expected)
494
+ validate_textfield_value(browser, how, what, expected, desc)
1202
495
  end
1203
496
  rescue
1204
497
  failed_to_log("Unable to '#{msg}': '#{$!}'")
@@ -1230,53 +523,6 @@ module Awetestlib
1230
523
  # failed_to_log("Textfield name='#{name}' could not be set to '#{value}': '#{$!}'. #{desc} (#{__LINE__})")
1231
524
  #end
1232
525
 
1233
- # @!endgroup Core
1234
-
1235
- # @!group Set
1236
-
1237
- # Set text field as identified by its *:name* attribute with value in *what* to the string specified in *value*.
1238
- # This method validates that the text field has been set to the specified value.
1239
- # The value verification can be turned off by setting *skip_value_check* to true.
1240
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1241
- # @param [String, Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
1242
- # @param [String] value A string to enter into the text field.
1243
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output.
1244
- # Required if *skip_value_check* is set to true.
1245
- # @param [Boolean] skip_value_check Forces verification of value in text field to pass.
1246
- # @return (see #click)
1247
- def set_textfield_by_name(browser, what, value, desc = '', skip_value_check = false)
1248
- set_text_field(browser, :name, what, value, desc, skip_value_check)
1249
- end
1250
-
1251
- # Set text field as identified by its *:id* attribute with value in *what* to the string specified in *value*.
1252
- # This method validates that the text field has been set to the specified value.
1253
- # The value verification can be turned off by setting *skip_value_check* to true.
1254
- # @param (see #set_textfield_by_name)
1255
- # @return (see #click)
1256
- def set_textfield_by_id(browser, what, value, desc = '', skip_value_check = false)
1257
- set_text_field(browser, :id, what, value, desc, skip_value_check)
1258
- end
1259
-
1260
- # Set text field as identified by its *:class* attribute with value in *what* to the string specified in *value*.
1261
- # This method validates that the text field has been set to the specified value.
1262
- # The value verification can be turned off by setting *skip_value_check* to true.
1263
- # @param (see #set_textfield_by_name)
1264
- # @return (see #click)
1265
- def set_textfield_by_title(browser, what, value, desc = '', skip_value_check = false)
1266
- set_text_field(browser, :title, what, value, desc, skip_value_check)
1267
- end
1268
-
1269
- # Set text field as identified by its *:class* attribute with value in *what* to the string specified in *value*.
1270
- # This method validates that the text field has been set to the specified value.
1271
- # The value verification can be turned off by setting *skip_value_check* to true.
1272
- # @param (see #set_textfield_by_name)
1273
- def set_textfield_by_class(browser, what, value, desc = '', skip_value_check = false)
1274
- set_text_field(browser, :class, what, value, desc, skip_value_check)
1275
- end
1276
-
1277
- # @!endgroup Set
1278
- # @!group Core
1279
-
1280
526
  # Fire an event on a specific DOM element identified by one of its attributes and that attribute's value.
1281
527
  #
1282
528
  # @example
@@ -1297,8 +543,7 @@ module Awetestlib
1297
543
  # @return (see #click)
1298
544
  #
1299
545
  def fire_event(browser, element, how, what, event, desc = '')
1300
- msg = "#{element.to_s.titlecase}: #{how}=>'#{what}' event:'#{event}'"
1301
- msg1 = "#{element.to_s.titlecase}(#{how}, '#{what}')"
546
+ msg = build_message("#{element.to_s.titlecase}: #{how}=>'#{what}' event:'#{event}'", desc)
1302
547
  begin
1303
548
  case element
1304
549
  when :link
@@ -1315,73 +560,16 @@ module Awetestlib
1315
560
  browser.element(how, what).fire_event(event)
1316
561
  end
1317
562
  rescue => e
1318
- if not rescue_me(e, __method__, "browser(#{msg1}).fire_event('#{event}')", "#{browser.class}")
563
+ unless rescue_me(e, __method__, rescue_me_command(element, how, what, __method__.to_s, event), "#{browser.class}")
1319
564
  raise e
1320
565
  end
1321
566
  end
1322
- passed_to_log("Fire event: #{msg}. #{desc}")
1323
- true
567
+ passed_to_log("Fire event: #{msg}. #{desc}")
568
+ true
1324
569
  rescue
1325
570
  failed_to_log("Unable to fire event: #{msg}. '#{$!}' #{desc}")
1326
571
  end
1327
572
 
1328
- # @!endgroup Core
1329
-
1330
- # @!group Fire Event
1331
-
1332
- # Fire an event on a link element identified by the value in its text (innerHTML)
1333
- #
1334
- # @example
1335
- # # html for a link element:
1336
- # # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
1337
- #
1338
- # fire_event_on_link_by_text(browser, 'Pickaxe', 'onMouseOver')
1339
- #
1340
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
1341
- # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
1342
- # @param [String] event A string identifying the event to be fired.
1343
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
1344
- # @return (see #click)
1345
- #
1346
- def fire_event_on_link_by_text(browser, what, event, desc = '')
1347
- fire_event(browser, :link, :text, what, event, desc)
1348
- end
1349
-
1350
- alias fire_event_text fire_event_on_link_by_text
1351
- alias fire_event_by_text fire_event_on_link_by_text
1352
-
1353
- # Fire an event on a link element identified by the value in its *:id* attribute.
1354
- #
1355
- # @example
1356
- # # html for a link element:
1357
- # # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
1358
- #
1359
- # fire_event_on_link_by_id(browser, 'one', 'onMouseOver')
1360
- #
1361
- # @param (see #fire_event_on_link_by_text)
1362
- # @return (see #click)
1363
- #
1364
- def fire_event_on_link_by_id(browser, what, event, desc = '')
1365
- fire_event(browser, :link, :id, what, event, desc)
1366
- end
1367
-
1368
- alias fire_event_id fire_event_on_link_by_id
1369
- alias fire_event_by_id fire_event_on_link_by_id
1370
-
1371
- # Fire an event on a image element identified by the value in its *:src* attribute.
1372
- # Take care to escape characters in the source url that are reserved by Regexp.
1373
- # @param (see #fire_event_on_link_by_text)
1374
- # @return (see #click)
1375
- #
1376
- def fire_event_on_image_by_src(browser, what, event, desc = '')
1377
- fire_event(browser, :img, :src, what, event, desc)
1378
- end
1379
-
1380
- alias fire_event_src fire_event_on_image_by_src
1381
- alias fire_event_image_by_src fire_event_on_image_by_src
1382
-
1383
- # @!endgroup Fire Event
1384
-
1385
573
  end
1386
574
  end
1387
575
  end