awetestlib 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.md +55 -0
  2. data/awetestlib.windows.gemspec +1 -1
  3. data/awetestlib_osx.gemspec +1 -0
  4. data/bin/AutoItX3.dll +0 -0
  5. data/bin/awetestlib +23 -3
  6. data/bin/awetestlib-helpers.rb +39 -0
  7. data/bin/awetestlib-netbeans-setup.rb +39 -0
  8. data/bin/awetestlib-regression-setup.rb +16 -0
  9. data/bin/awetestlib-rubymine-setup.rb +33 -0
  10. data/images/logo.png +0 -0
  11. data/lib/awetestlib.rb +4 -4
  12. data/lib/awetestlib/html_report.rb +171 -0
  13. data/lib/{regression → awetestlib}/logging.rb +13 -46
  14. data/lib/awetestlib/regression/browser.rb +1233 -0
  15. data/lib/awetestlib/regression/drag_and_drop.rb +379 -0
  16. data/lib/awetestlib/regression/find.rb +431 -0
  17. data/lib/awetestlib/regression/legacy.rb +45 -0
  18. data/lib/awetestlib/regression/page_data.rb +190 -0
  19. data/lib/awetestlib/regression/runner.rb +307 -0
  20. data/lib/awetestlib/regression/tables.rb +491 -0
  21. data/lib/awetestlib/regression/user_input.rb +1256 -0
  22. data/lib/awetestlib/regression/utilities.rb +895 -0
  23. data/lib/awetestlib/regression/validations.rb +1184 -0
  24. data/lib/awetestlib/regression/waits.rb +391 -0
  25. data/lib/awetestlib/runner.rb +16 -0
  26. data/lib/version.rb +2 -2
  27. data/setup_samples/sample_netbeans/demo.rb +86 -0
  28. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -0
  29. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -0
  30. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +1 -0
  31. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -0
  32. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -0
  33. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -0
  34. data/setup_samples/sample_rubymine/.idea/.name +1 -0
  35. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -0
  36. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -0
  37. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -0
  38. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -0
  39. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +5 -0
  40. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -0
  41. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -0
  42. data/setup_samples/sample_rubymine/demo.rb +86 -0
  43. metadata +64 -17
  44. data/lib/regression/browser.rb +0 -1259
  45. data/lib/regression/drag_and_drop.rb +0 -374
  46. data/lib/regression/find.rb +0 -426
  47. data/lib/regression/legacy.rb +0 -40
  48. data/lib/regression/page_data.rb +0 -185
  49. data/lib/regression/runner.rb +0 -278
  50. data/lib/regression/tables.rb +0 -486
  51. data/lib/regression/user_input.rb +0 -1255
  52. data/lib/regression/utilities.rb +0 -891
  53. data/lib/regression/validations.rb +0 -1179
  54. data/lib/regression/waits.rb +0 -387
@@ -1,1255 +0,0 @@
1
- module UserInput
2
-
3
- =begin rdoc
4
- :category: A_rdoc_test
5
- Click a specific DOM element by one of its attributes and that attribute's value.
6
-
7
- _Parameters_::
8
-
9
- *browser* - a reference to the browser window or container element to be tested
10
-
11
- *element* - the kind of element to click. Must be one of the elements recognized by Watir.
12
- Some common values are :link, :button, :image, :div, :span.
13
-
14
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
15
- Common values: :text, :id, :title, :name, :class, :href (:link only)
16
-
17
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
18
-
19
- *desc* - a string containing a message or description intended to appear in the log and/or report output
20
-
21
- _Example_
22
-
23
- # html for a link element:
24
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
25
- click(browser, :link, :text, 'Pickaxe')
26
-
27
- =end
28
-
29
- def click(browser, element, how, what, desc = '')
30
- #debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
31
- msg = "Click #{element} :#{how}=>'#{what}'"
32
- msg << ", '#{desc}'" if desc.length > 0
33
- msg1 = "#{element}(#{how}, '#{what}')"
34
- begin
35
- case element
36
- when :link
37
- browser.link(how, what).click
38
- when :button
39
- browser.button(how, what).click
40
- when :image
41
- browser.image(how, what).click
42
- when :radio
43
- case how
44
- when :index
45
- set_radio_by_index(browser, what, desc)
46
- else
47
- browser.radio(how, what).set
48
- end
49
- when :span
50
- browser.span(how, what).click
51
- when :div
52
- browser.div(how, what).click
53
- when :cell
54
- browser.cell(how, what).click
55
- else
56
- browser.element(how, what).click
57
- end
58
- rescue => e
59
- if not rescue_me(e, __method__, "browser(#{msg1}).click", "#{browser.class}")
60
- raise e
61
- end
62
- end
63
- if validate(browser, @myName, __LINE__)
64
- passed_to_log(msg)
65
- true
66
- end
67
- rescue
68
- failed_to_log("Unable to #{msg}. '#{$!}'")
69
- end
70
-
71
- =begin rdoc
72
- :category: A_rdoc_test
73
- Click a specific DOM element by one of its attributes and that attribute's value and
74
- do not wait for the browser to finish reloading. Used when a modal popup or alert is expected. Allows the script
75
- to keep running so the popup can be handled.
76
-
77
- _Parameters_::
78
-
79
- *browser* - a reference to the browser window to be tested
80
-
81
- *element* - the kind of element to click. Must be one of the elements recognized by Watir.
82
- Some common values are :link, :button, :image, :div, :span.
83
-
84
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
85
- Common values: :text, :id, :title, :name, :class, :href (:link only)
86
-
87
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
88
-
89
- *desc* - a string containing a message or description intended to appear in the log and/or report output
90
-
91
- _Example_
92
-
93
- # html for a link element:
94
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
95
- click_no_wait(browser, :link, :text, 'Pickaxe')
96
-
97
- =end
98
-
99
- def click_no_wait(browser, element, how, what, desc = '')
100
- debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
101
- msg = "Click no wait #{element} :#{how}=>'#{what}'"
102
- msg << ", '#{desc}'" if desc.length > 0
103
- msg1 = "#{element}(#{how}, '#{what}'"
104
- begin
105
- case element
106
- when :link
107
- browser.link(how, what).click_no_wait
108
- when :button
109
- browser.button(how, what).click_no_wait
110
- when :image
111
- browser.image(how, what).click_no_wait
112
- when :radio
113
- case how
114
- when :index
115
- set_radio_no_wait_by_index(browser, what, desc)
116
- else
117
- browser.radio(how, what).click_no_wait
118
- end
119
- when :span
120
- browser.span(how, what).click_no_wait
121
- when :div
122
- browser.div(how, what).click_no_wait
123
- when :checkbox
124
- browser.checkbox(how, what).click_no_wait
125
- when :cell
126
- browser.cell(how, what).click_no_wait
127
- else
128
- browser.element(how, what).click_no_wait
129
- end
130
- rescue => e
131
- if not rescue_me(e, __method__, "browser(#{msg1}').click_no_wait", "#{browser.class}")
132
- raise e
133
- end
134
- end
135
- if validate(browser, @myName, __LINE__)
136
- passed_to_log(msg)
137
- true
138
- end
139
- rescue
140
- failed_to_log("Unable to #{msg} '#{$!}'")
141
- sleep_for(1)
142
- end
143
-
144
- # :category: User Input
145
- def click_button_by_id(browser, strg, desc = '')
146
- click(browser, :button, :id, strg, desc)
147
- end
148
-
149
- # :category: User Input
150
- def click_link_by_index(browser, strg, desc = '')
151
- click(browser, :link, :index, strg, desc)
152
- end
153
-
154
- # :category: User Input
155
- def click_link_by_href(browser, strg, desc = '')
156
- click(browser, :link, :href, strg, desc)
157
- end
158
-
159
- alias click_href click_link_by_href
160
- # :category: User Input
161
- def click_link_no_wait_by_href(browser, strg, desc = '')
162
- click_no_wait(browser, :link, :href, strg, desc)
163
- end
164
-
165
- alias click_href_no_wait click_link_no_wait_by_href
166
- # :category: User Input
167
- def click_button_by_index(browser, index, desc = '')
168
- click(browser, :button, :index, index, desc)
169
- end
170
-
171
- # :category: User Input
172
- def click_button_by_name(browser, strg, desc = '')
173
- click(browser, :button, :name, strg, desc)
174
- end
175
-
176
- # :category: User Input
177
- def click_button_by_text(browser, strg, desc = '')
178
- click(browser, :button, :text, strg, desc)
179
- end
180
-
181
- # :category: User Input
182
- def click_button_by_class(browser, strg, desc = '')
183
- click(browser, :button, :class, strg, desc)
184
- end
185
-
186
- # :category: User Input
187
- def click_button_no_wait_by_id(browser, strg, desc = '')
188
- click_no_wait(browser, :button, :id, strg, desc)
189
- end
190
-
191
- alias click_button_by_id_no_wait click_button_no_wait_by_id
192
- # :category: User Input
193
- def click_button_no_wait_by_name(browser, strg, desc = '')
194
- click_no_wait(browser, :button, :name, strg, desc)
195
- end
196
-
197
- # :category: User Input
198
- def click_button_no_wait_by_class(browser, strg, desc = '')
199
- click_no_wait(browser, :button, :class, strg, desc)
200
- end
201
-
202
- alias click_button_by_class_no_wait click_button_no_wait_by_class
203
- # :category: User Input
204
- def click_button_by_value(browser, strg, desc = '')
205
- click(browser, :button, :value, strg, desc)
206
- end
207
-
208
- # :category: User Input
209
- def click_button_by_title(browser, strg, desc = '')
210
- click(browser, :button, :title, strg, desc)
211
- end
212
-
213
- # :category: User Input
214
- def click_button_by_xpath_and_id(browser, strg, desc = '')
215
- msg = "Click button by xpath and id '#{strg}' #{desc}"
216
- if browser.button(:xpath, "//a[@id = '#{strg}']").click
217
- passed_to_log(msg)
218
- true
219
- else
220
- failed_to_log(msg)
221
- end
222
- rescue
223
- failed_to_log("Unable to click button by xpath and id '#{strg}' #{desc} '#{$!}' (#{__LINE__})")
224
- end
225
-
226
- alias click_button_by_xpath click_button_by_xpath_and_id
227
-
228
- =begin rdoc
229
- :category: A_rdoc_test
230
- Click a link identified by the value in its id attribute. Calls click()
231
-
232
- _Parameters_::
233
-
234
- *browser* - a reference to the browser window to be tested
235
-
236
- *strg* - a string or a regular expression to be found in the id attribute that uniquely identifies the element.
237
-
238
- *desc* - a string containing a message or description intended to appear in the log and/or report output
239
-
240
-
241
- _Example_
242
-
243
- # html for a link element:
244
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
245
- click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
246
-
247
- =end
248
-
249
- def click_link_by_id(browser, strg, desc = '')
250
- click(browser, :link, :id, strg, desc)
251
- end
252
-
253
- # :category: A_rdoc_test
254
- alias click_id click_link_by_id
255
-
256
- # :category: User Input
257
- def click_link_by_name(browser, strg, desc = '')
258
- click(browser, :link, :name, strg, desc)
259
- end
260
-
261
- alias click_name click_link_by_name
262
- # :category: User Input
263
- def click_link_by_xpath_and_id(browser, strg, desc = '')
264
- msg = "Click link by xpath and id '#{strg}' #{desc}"
265
- if browser.link(:xpath, "//a[@id = '#{strg}']").click
266
- passed_to_log(msg)
267
- true
268
- else
269
- failed_to_log(msg)
270
- end
271
- rescue
272
- failed_to_log("Unable click on link by xpath and id '#{strg}' #{desc} '#{$!}' (#{__LINE__})")
273
- end
274
-
275
- alias click_link_by_xpath click_link_by_xpath_and_id
276
-
277
- # :category: User Input
278
- def click_link_no_wait_by_id(browser, strg, desc = '')
279
- click_no_wait(browser, :link, :id, strg, desc)
280
- end
281
-
282
- alias click_no_wait_id click_link_no_wait_by_id
283
- alias click_no_wait_by_id click_link_no_wait_by_id
284
- alias click_id_no_wait click_link_no_wait_by_id
285
- alias click_no_wait_link_by_id click_link_no_wait_by_id
286
-
287
- # :category: User Input
288
- def click_file_field_by_id(browser, strg, desc = '')
289
- click(browser, :file_field, :id, strg, desc)
290
- end
291
-
292
- # :category: User Input
293
- def click_img_by_alt(browser, strg, desc = '')
294
- click(browser, :image, :alt, strg, desc)
295
- end
296
-
297
- # :category: User Input
298
- def click_img_by_title(browser, strg, desc = '')
299
- click(browser, :image, :title, strg, desc)
300
- end
301
-
302
- # :category: User Input
303
- def click_img_by_xpath_and_name(browser, strg, desc = '')
304
- msg = "Click image by xpath where name='#{strg}' #{desc}"
305
- if browser.link(:xpath, "//input[@name = '#{strg}']").click
306
- passed_to_log(msg)
307
- true
308
- else
309
- failed_to_log(msg)
310
- end
311
- rescue
312
- failed_to_log("Unable to click image by xpath where name='#{strg}' #{desc} '#{$!}'")
313
- end
314
-
315
- alias click_img_by_xpath click_img_by_xpath_and_name
316
- alias click_image_by_xpath click_img_by_xpath_and_name
317
- alias click_image_by_xpath_and_name click_img_by_xpath_and_name
318
-
319
- # :category: User Input
320
- def click_img_no_wait_by_alt(browser, strg, desc = '')
321
- click_no_wait(browser, :image, :alt, strg, desc)
322
- end
323
-
324
- alias click_img_by_alt_no_wait click_img_no_wait_by_alt
325
- # :category: User Input
326
- def click_img_by_src(browser, strg, desc = '')
327
- click(browser, :image, :src, strg, desc)
328
- end
329
-
330
- # :category: User Input
331
- def click_img_by_src_and_index(browser, strg, index, desc = '')
332
- msg = "Click image by src='#{strg}' and index=#{index}"
333
- msg << " #{desc}" if desc.length > 0
334
- browser.image(:src => strg, :index => index).click
335
- if validate(browser, @myName, __LINE__)
336
- passed_to_log(msg)
337
- true
338
- end
339
- rescue
340
- failed_to_log("Unable to #{msg} '#{$!}'")
341
- end
342
-
343
- # :category: User Input
344
- def click_link_by_value(browser, strg, desc = '')
345
- click(browser, :link, :value, strg, desc)
346
- end
347
-
348
- =begin rdoc
349
- :category: A_rdoc_test
350
- Click a link identified by the value in its text attribute. Calls click()
351
-
352
- _Parameters_::
353
-
354
- *browser* - a reference to the browser window to be tested
355
-
356
- *strg* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
357
-
358
- *desc* - a string containing a message or description intended to appear in the log and/or report output
359
-
360
-
361
- _Example_
362
-
363
- # html for a link element:
364
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
365
- click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
366
-
367
- =end
368
-
369
- def click_link_by_text(browser, strg, desc = '')
370
- click(browser, :link, :text, strg, desc)
371
- end
372
-
373
- alias click_link click_link_by_text
374
- # :category: A_rdoc_test
375
- alias click_text click_link_by_text
376
- alias click_js_button click_link_by_text
377
-
378
- # :category: User Input
379
- def click_link_by_class(browser, strg, desc = '')
380
- click(browser, :link, :class, strg, desc)
381
- end
382
-
383
- alias click_class click_link_by_class
384
-
385
- # :category: User Input
386
- def click_button_no_wait_by_text(browser, strg, desc = '')
387
- click_no_wait(browser, :button, :text, strg, desc)
388
- end
389
-
390
- # :category: User Input
391
- def click_button_no_wait_by_value(browser, strg, desc = '')
392
- click_no_wait(browser, :button, :value, strg, desc)
393
- end
394
-
395
- # :category: User Input
396
- def click_link_by_name_no_wait(browser, strg, desc = '')
397
- click_no_wait(browser, :link, :name, strg, desc)
398
- end
399
-
400
- alias click_no_wait_name click_link_by_name_no_wait
401
- alias click_name_no_wait click_link_by_name_no_wait
402
-
403
- # :category: User Input
404
- def click_link_by_text_no_wait(browser, strg, desc = '')
405
- click_no_wait(browser, :link, :text, strg, desc)
406
- end
407
-
408
- alias click_no_wait_text click_link_by_text_no_wait
409
- alias click_text_no_wait click_link_by_text_no_wait
410
-
411
- # :category: User Input
412
- def click_span_by_text(browser, strg, desc = '')
413
- if not desc and not strg.match(/Save|Open|Close|Submit|Cancel/)
414
- desc = 'to navigate to selection'
415
- end
416
- msg = "Click span containing text '#{strg}'."
417
- msg << " #{desc}" if desc.length > 0
418
- if validate(browser, @myName, __LINE__)
419
- passed_to_log("#{msg}")
420
- end
421
- rescue
422
- failed_to_log("Unable to #{msg}: '#{$!}'")
423
- end
424
-
425
- # TODO no logging yet. slow.# :category: User Input
426
- def click_span_with_text(browser, trgt, desc = '')
427
- msg = "Find and click span containing text '#{trgt}'."
428
- msg << " #{desc}" if desc.length > 0
429
- spans = browser.spans
430
- x = 0
431
- spans.each do |span|
432
- x += 1
433
- debug_to_log("Span #{x}: #{span.text}")
434
- aText = span.text
435
- if aText and aText.size > 0
436
- if aText =~ /#{trgt}/
437
- break
438
- end
439
- end
440
- end
441
- spans[x].click
442
- end
443
-
444
- # :category: User Input
445
- def click_link_by_title(browser, strg, desc = '')
446
- click(browser, :link, :title, strg, desc)
447
- end
448
-
449
- alias click_title click_link_by_title
450
- # :category: User Input
451
- def click_title_no_wait(browser, strg, desc = '')
452
- click_no_wait(browser, :link, :title, strg, desc)
453
- end
454
-
455
- # :category: User Input
456
- def click_table_row_with_text_by_id(browser, ptrn, strg, column = nil)
457
- msg = "id=#{ptrn} row with text='#{strg}"
458
- table = get_table_by_id(browser, /#{ptrn}/)
459
- if table
460
- index = get_index_of_row_with_text(table, strg, column)
461
- if index
462
- table[index].click
463
- if validate(browser, @myName, __LINE__)
464
- passed_to_log("Click #{msg} row index=#{index}.")
465
- index
466
- end
467
- else
468
- failed_to_log("Table #{msg} not found to click.")
469
- end
470
- else
471
- failed_to_log("Table id=#{ptrn} not found.")
472
- end
473
- rescue
474
- failed_to_log("Unable to click table #{msg}: '#{$!}' (#{__LINE__}) ")
475
- end
476
-
477
- # :category: User Input
478
- def click_table_row_with_text_by_index(browser, idx, strg, column = nil)
479
- msg = "index=#{idx} row with text='#{strg}"
480
- table = get_table_by_index(browser, idx)
481
- if table
482
- index = get_index_of_row_with_text(table, strg, column)
483
- if index
484
- table[index].click
485
- if validate(browser, @myName, __LINE__)
486
- passed_to_log("Click #{msg} row index=#{index}.")
487
- index
488
- end
489
- else
490
- failed_to_log("Table #{msg} not found to click.")
491
- end
492
- else
493
- failed_to_log("Table id=#{ptrn} not found.")
494
- end
495
- rescue
496
- failed_to_log("Unable to click table #{msg}: '#{$!}' (#{__LINE__}) ")
497
- end
498
-
499
- def double_click_table_row_with_text_by_id(browser, ptrn, strg, column = nil)
500
- msg = "id=#{ptrn} row with text='#{strg}"
501
- table = get_table_by_id(browser, /#{ptrn}/)
502
- if table
503
- index = get_index_of_row_with_text(table, strg, column)
504
- if index
505
- table[index].fire_event('ondblclick')
506
- if validate(browser, @myName, __LINE__)
507
- passed_to_log("Double click #{msg} row index=#{index}.")
508
- index
509
- end
510
- else
511
- failed_to_log("Table #{msg} not found to double click.")
512
- end
513
- else
514
- failed_to_log("Table id=#{ptrn} not found.")
515
- end
516
- rescue
517
- failed_to_log("Unable to double click table #{msg}: '#{$!}' (#{__LINE__}) ")
518
- end
519
-
520
- def double_click_table_row_with_text_by_index(browser, idx, strg, column = nil)
521
- msg = "index=#{idx} row with text='#{strg}"
522
- table = get_table_by_index(browser, idx)
523
- if table
524
- index = get_index_of_row_with_text(table, strg, column)
525
- if index
526
- row = table[index]
527
- table[index].fire_event('ondblclick')
528
- row.fire_event('ondblclick')
529
- if validate(browser, @myName, __LINE__)
530
- passed_to_log("Double click #{msg} row index=#{index}.")
531
- index
532
- end
533
- else
534
- failed_to_log("Table #{msg} not found to double click.")
535
- end
536
- else
537
- failed_to_log("Table id=#{ptrn} not found.")
538
- end
539
- rescue
540
- failed_to_log("Unable to double click table #{msg}: '#{$!}' (#{__LINE__}) ")
541
- end
542
-
543
- def click_popup_button(title, button, waitTime= 9, user_input=nil)
544
- #TODO: is winclicker still viable/available?
545
- wc = WinClicker.new
546
- if wc.clickWindowsButton(title, button, waitTime)
547
- passed_to_log("Window '#{title}' button '#{button}' found and clicked.")
548
- true
549
- else
550
- failed_to_log("Window '#{title}' button '#{button}' not found. (#{__LINE__})")
551
- end
552
- wc = nil
553
- # get a handle if one exists
554
- # hwnd = $ie.enabled_popup(waitTime)
555
- # if (hwnd) # yes there is a popup
556
- # w = WinClicker.new
557
- # if ( user_input )
558
- # w.setTextValueForFileNameField( hwnd, "#{user_input}" )
559
- # end
560
- # # I put this in to see the text being input it is not necessary to work
561
- # sleep 3
562
- # # "OK" or whatever the name on the button is
563
- # w.clickWindowsButton_hwnd( hwnd, "#{button}" )
564
- # #
565
- # # this is just cleanup
566
- # w=nil
567
- # end
568
- end
569
-
570
- def select_option(browser, how, what, which, value, desc = '')
571
- msg = "Select option #{which}='#{value}' from list #{how}=#{what}. #{desc}"
572
- list = browser.select_list(how, what)
573
- case which
574
- when :text
575
- list.select(value)
576
- when :value
577
- list.select_value(value)
578
- when :index
579
- all = list.getAllContents
580
- txt = all[value]
581
- list.select(txt)
582
- else
583
- na = "#{__method__} cannot support select by '#{which}'. (#{msg})"
584
- debug_to_log(na, __LINE__, true)
585
- raise na
586
- end
587
- passed_to_log(msg)
588
- rescue
589
- failed_to_log("#Unable to #{msg}': '#{$!}'")
590
- end
591
-
592
- def select_option_from_list(list, what, what_strg, desc = '')
593
- ok = true
594
- msg = "#{__method__.to_s.titleize} "
595
- if list
596
- msg << "list id=#{list.id}: "
597
- case what
598
- when :text
599
- list.select(what_strg) #TODO: regex?
600
- when :value
601
- list.select_value(what_strg) #TODO: regex?
602
- when :index
603
- list.select(list.getAllContents[what_strg.to_i])
604
- else
605
- msg << "select by #{what} not supported. #{desc} (#{__LINE__})"
606
- failed_to_log(msg)
607
- ok = false
608
- end
609
- if ok
610
- msg << "#{what}='#{what_strg}' selected. #{desc}"
611
- passed_to_log(msg)
612
- true
613
- end
614
- else
615
- failed_to_log("#{__method__.to_s.titleize} list not found. #{desc} (#{__LINE__})")
616
- end
617
- rescue
618
- failed_to_log("#{__method__.to_s.titleize}: #{what}='#{what_strg}' could not be selected: '#{$!}'. #{desc} (#{__LINE__})")
619
- end
620
-
621
- =begin rdoc
622
- :category: A_rdoc_test
623
- Select an option from a specific drop down list. The drop down (select list) is id
624
-
625
- _Parameters_::
626
-
627
- *browser* - a reference to the browser window to be tested
628
-
629
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
630
- Common values: :text, :id, :title, :name, :class, :href (:link only)
631
-
632
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
633
-
634
- *desc* - a string containing a message or description intended to appear in the log and/or report output
635
-
636
- _Example_
637
-
638
- # html for a link element:
639
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
640
- click_no_wait(browser, :link, :text, 'Pickaxe')
641
-
642
- =end
643
-
644
- def select_option_by_id_and_option_text(browser, strg, option, nofail=false, desc = '')
645
- msg = "Select list id=#{strg} option text='#{option}' selected."
646
- msg << " #{desc}" if desc.length > 0
647
- list = browser.select_list(:id, strg)
648
- list.select(option)
649
- # browser.select_list(:id, strg).select(option) #(browser.select_list(:id, strg).getAllContents[option])
650
- if validate(browser, @myName, __LINE__)
651
- passed_to_log(msg)
652
- true
653
- end
654
- rescue
655
- if !nofail
656
- failed_to_log("#{msg} '#{$!}'")
657
- end
658
- end
659
-
660
- alias select_option_by_id select_option_by_id_and_option_text
661
- alias select_option_by_id_and_text select_option_by_id_and_option_text
662
-
663
- def select_option_by_name_and_option_text(browser, strg, option, desc = '')
664
- msg = "Select list name=#{strg} option text='#{option}' selected."
665
- msg << " #{desc}" if desc.length > 0
666
- begin
667
- list = browser.select_list(:name, strg)
668
- rescue => e
669
- if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}")
670
- raise e
671
- end
672
- end
673
- begin
674
- list.select(option)
675
- rescue => e
676
- if not rescue_me(e, __method__, "#{__LINE__}: select_list#select('#{option}')", "#{browser.class}")
677
- raise e
678
- end
679
- end
680
- if validate(browser, @myName, __LINE__)
681
- passed_to_log(msg)
682
- true
683
- end
684
- rescue
685
- failed_to_log("#{msg} '#{$!}'")
686
- end
687
-
688
- alias select_option_by_name select_option_by_name_and_option_text
689
-
690
- def select_option_by_title_and_option_text(browser, strg, option, desc = '')
691
- msg = "Select list name=#{strg} option text='#{option}' selected."
692
- msg << " #{desc}" if desc.length > 0
693
- browser.select_list(:title, strg).select(option)
694
- if validate(browser, @myName, __LINE__)
695
- passed_to_log(msg)
696
- end
697
- rescue
698
- failed_to_log("#{msg} '#{$!}'")
699
- end
700
-
701
- def select_option_by_class_and_option_text(browser, strg, option, desc = '')
702
- msg = "Select list class=#{strg} option text='#{option}' selected."
703
- msg << " #{desc}" if desc.length > 0
704
- browser.select_list(:class, strg).select(option)
705
- if validate(browser, @myName, __LINE__)
706
- passed_to_log(msg)
707
- true
708
- end
709
- rescue
710
- failed_to_log("#{msg} '#{$!}'")
711
- end
712
-
713
- def select_option_by_name_and_option_value(browser, strg, option, desc = '')
714
- msg = "Select list name=#{strg} option value='#{option}' selected."
715
- msg << " #{desc}" if desc.length > 0
716
- begin
717
- list = browser.select_list(:name, strg)
718
- rescue => e
719
- if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}")
720
- raise e
721
- end
722
- end
723
- begin
724
- list.select_value(option)
725
- rescue => e
726
- if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}")
727
- raise e
728
- end
729
- end
730
- if validate(browser, @myName, __LINE__)
731
- passed_to_log(msg)
732
- true
733
- end
734
- rescue
735
- failed_to_log("#{msg} '#{$!}'")
736
- end
737
-
738
- def select_option_by_id_and_option_value(browser, strg, option, desc = '')
739
- msg = "Select list name=#{strg} option value='#{option}' selected."
740
- msg << " #{desc}" if desc.length > 0
741
- begin
742
- list = browser.select_list(:id, strg)
743
- rescue => e
744
- if not rescue_me(e, __method__, "#{__LINE__}: select_list(:text,'#{strg}')", "#{browser.class}")
745
- raise e
746
- end
747
- end
748
- sleep(0.5) unless @targetBrowser.abbrev == 'IE'
749
- begin
750
- list.select_value(option)
751
- rescue => e
752
- if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}")
753
- raise e
754
- end
755
- end
756
- if validate(browser, @myName, __LINE__)
757
- passed_to_log(msg)
758
- true
759
- end
760
- rescue
761
- failed_to_log("#{msg} '#{$!}'")
762
- end
763
-
764
- def select_option_by_id_and_index(browser, strg, idx, desc = '')
765
- msg = "Select list id=#{strg} index='#{idx}' selected."
766
- msg << " #{desc}" if desc.length > 0
767
- list = browser.select_list(:id, strg)
768
- all = list.getAllContents
769
- txt = all[idx]
770
- browser.select_list(:id, strg).set(browser.select_list(:id, strg).getAllContents[idx])
771
- if validate(browser, @myName, __LINE__)
772
- passed_to_log(msg)
773
- true
774
- end
775
- rescue
776
- failed_to_log("#{msg} '#{$!}'")
777
- end
778
-
779
- def select_option_by_name_and_index(browser, strg, idx)
780
- # TODO add check that both list and option exist
781
- msg = "Select list name=#{strg} index='#{idx}' selected."
782
- msg << " #{desc}" if desc.length > 0
783
- browser.select_list(:name, strg).set(browser.select_list(:name, strg).getAllContents[idx])
784
- if validate(browser, @myName, __LINE__)
785
- passed_to_log(msg)
786
- true
787
- end
788
- rescue
789
- failed_to_log("#{msg} '#{$!}'")
790
- end
791
-
792
- def select_option_by_xpath_and_index(browser, strg, idx)
793
- msg = "Select list xpath=#{strg} index='#{idx}' selected."
794
- msg << " #{desc}" if desc.length > 0
795
- browser.select_list(:xpath, strg).set(browser.select_list(:xpath, strg).getAllContents[idx])
796
- if validate(browser, nil, __LINE__)
797
- passed_to_log(msg)
798
- true
799
- end
800
- rescue
801
- failed_to_log("#{msg} '#{$!}'")
802
- end
803
-
804
- def set(browser, element, how, what, value = nil, desc = '')
805
- msg = "Set #{element} #{how}=>'#{what}' "
806
- msg << ", :value=>#{value} " if value
807
- msg << " '#{desc}' " if desc.length > 0
808
- case element
809
- when :radio
810
- browser.radio(how, what, value).set
811
- when :checkbox
812
- browser.checkbox(how, what, value).set
813
- else
814
- failed_to_log("#{__method__}: #{element} not supported")
815
- end
816
- if validate(browser, @myName, __LINE__)
817
- passed_to_log(msg)
818
- true
819
- end
820
- rescue
821
- failed_to_log("#{msg} '#{$!}'")
822
- end
823
-
824
- def set_checkbox(browser, how, what, value, desc = '')
825
- set(browser, :checkbox, how, what, value, desc)
826
- end
827
-
828
- def set_checkbox_by_class(browser, strg, value = nil, desc = '')
829
- set(browser, :checkbox, :class, strg, value, desc)
830
- end
831
-
832
- def set_checkbox_by_id(browser, strg, value = nil, desc = '')
833
- set(browser, :checkbox, :id, strg, value, desc)
834
- end
835
-
836
- def set_checkbox_by_name(browser, strg, value = nil, desc = '')
837
- set(browser, :checkbox, :name, strg, value, desc)
838
- end
839
-
840
- def set_checkbox_by_title(browser, strg, value = nil, desc = '')
841
- set(browser, :checkbox, :title, strg, value, desc)
842
- end
843
-
844
- def set_checkbox_by_value(browser, strg, desc = '')
845
- set(browser, :checkbox, :value, strg, nil, desc)
846
- end
847
-
848
- def set_radio(browser, how, what, value = nil, desc = '')
849
- set(browser, :radio, how, what, value, desc)
850
- end
851
-
852
- def set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '')
853
- msg = "Set radio #{how1}='#{what1}', #{how2}= #{what2}"
854
- msg << " '#{desc}' " if desc.length > 0
855
- browser.radio(how1 => what1, how2 => what2).set
856
- if validate(browser, @myName, __LINE__)
857
- passed_to_log(msg)
858
- true
859
- end
860
- rescue
861
- failed_to_log("#{msg} '#{$!}'")
862
- end
863
-
864
- def set_radio_by_class(browser, strg, value = nil, desc = '')
865
- set(browser, :radio, :class, strg, value, desc)
866
- end
867
-
868
- def set_radio_by_id(browser, strg, value = nil, desc = '')
869
- set(browser, :radio, :id, strg, value, desc)
870
- end
871
-
872
- def set_radio_by_index(browser, index, desc = '')
873
- set(browser, :radio, :index, index, value, desc)
874
- end
875
-
876
- def set_radio_by_name(browser, strg, value = nil, desc = '')
877
- set(browser, :radio, :name, strg, value, desc)
878
- end
879
-
880
- def set_radio_by_title(browser, strg, value = nil, desc = '')
881
- set(browser, :radio, :title, strg, value, desc)
882
- end
883
-
884
- def set_radio_by_value(browser, strg, desc = '')
885
- set(browser, :radio, :value, strg, nil, desc)
886
- end
887
-
888
- def set_radio_no_wait_by_index(browser, index, desc = '')
889
- #TODO: Not supported by Watir 1.8.x
890
- msg = "Radio :index=#{index} "
891
- radios = browser.radios
892
- debug_to_log("\n#{radios}")
893
- radio = radios[index]
894
- debug_to_log("\n#{radio}")
895
- radio.click_no_wait
896
- if validate(browser)
897
- msg << 'set ' + desc
898
- passed_to_log(msg)
899
- true
900
- end
901
- rescue
902
- msg << 'not found ' + desc
903
- failed_to_log("#{msg} (#{__LINE__})")
904
- end
905
-
906
- def set_radio_by_name_and_index(browser, name, index, desc = '')
907
- set_radio_two_attributes(browser, :name, name, :index, index, desc)
908
- end
909
-
910
- def set_radio_by_name_and_text(browser, name, text, desc = '')
911
- set_radio_two_attributes(browser, :name, name, :text, text, desc)
912
- end
913
-
914
- def set_radio_by_value_and_index(browser, value, index, desc = '')
915
- set_radio_two_attributes(browser, :value, value, :index, index, desc)
916
- end
917
-
918
- def set_radio_by_name_and_value(browser, strg, value, desc = '')
919
- set_radio(browser, :name, strg, value, desc)
920
- end
921
-
922
- def clear(browser, element, how, what, value = nil, desc = '')
923
- msg = "Clear #{element} #{how}=>'#{what}' "
924
- msg << ", value=>#{value} " if value
925
- msg << " '#{desc}' " if desc.length > 0
926
- case element
927
- when :radio
928
- browser.radio(how, what, value).clear
929
- when :checkbox
930
- browser.checkbox(how, what, value).clear
931
- when :text_field
932
- browser.text_field(how, what).set('')
933
- else
934
- failed_to_log("#{__method__}: #{element} not supported")
935
- end
936
- if validate(browser, @myName, __LINE__)
937
- passed_to_log(msg)
938
- true
939
- end
940
- rescue
941
- failed_to_log("#{msg} '#{$!}'")
942
- end
943
-
944
- def clear_checkbox(browser, how, what, value = nil, desc = '')
945
- clear(browser, :checkbox, how, what, value, desc)
946
- end
947
-
948
- def clear_checkbox_by_name(browser, strg, value = nil, desc = '')
949
- clear(browser, :checkbox, :name, strg, value, desc)
950
- end
951
-
952
- def clear_checkbox_by_id(browser, strg, value = nil, desc = '')
953
- clear(browser, :checkbox, :id, strg, value, desc)
954
- end
955
-
956
- def clear_radio(browser, how, what, value = nil, desc = '')
957
- clear(browser, :radio, how, what, value, desc)
958
- end
959
-
960
- # Set skip_value_check = true when string is altered by application and/or
961
- # this method will be followed by validate_text
962
- def clear_textfield(browser, how, which, skip_value_check = false)
963
- if browser.text_field(how, which).exists?
964
- tf = browser.text_field(how, which)
965
- if validate(browser, @myName, __LINE__)
966
- tf.clear
967
- if validate(browser, @myName, __LINE__)
968
- if tf.value == ''
969
- passed_to_log("Textfield #{how}='#{which}' cleared.")
970
- true
971
- elsif skip_value_check
972
- passed_to_log("Textfield #{how}='#{which}' cleared. (skip value check)")
973
- true
974
- else
975
- failed_to_log("Textfield #{how}='#{which}' not cleared: Found:'#{tf.value}'. (#{__LINE__})")
976
- end
977
- end
978
- end
979
- else
980
- failed_to_log("Textfield id='#{id}' to clear. (#{__LINE__})")
981
- end
982
- rescue
983
- failed_to_log("Textfield id='#{id}' could not be cleared: '#{$!}'. (#{__LINE__})")
984
- end
985
-
986
- def set_file_field(browser, how, what, filespec, desc = '')
987
- msg = "Set file field #{how}=>#{what} to '#{filespec}."
988
- msg << " #{desc}" if desc.length > 0
989
- ff = browser.file_field(how, what)
990
- if ff
991
- ff.set filespec
992
- sleep_for(8)
993
- if validate(browser, @myName, __LINE__)
994
- passed_to_log(msg)
995
- true
996
- end
997
- else
998
- failed_to_log("#{msg} File field not found.")
999
- end
1000
- rescue
1001
- failed_to_log("Unable to #{msg} '#{$!}'")
1002
- end
1003
-
1004
- def set_file_field_by_name(browser, strg, path, desc = '')
1005
- set_file_field(browser, :name, strg, path, desc)
1006
- end
1007
-
1008
- def set_file_field_by_id(browser, strg, path, desc = '')
1009
- set_file_field(browser, :id, strg, path, desc)
1010
- end
1011
-
1012
- =begin rdoc
1013
- :category: A_rdoc_test
1014
- Enter a string into a text field element identified by an attribute type and a value.
1015
- After the entry the value in the text field is validated against the input value unless the *skip_value_check*
1016
- parameter is set to true
1017
-
1018
- _Parameters_::
1019
-
1020
- *browser* - a reference to the browser window to be tested
1021
-
1022
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
1023
- Common values: :text, :id, :title, :name, :class, :href (:link only)
1024
-
1025
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
1026
-
1027
- *value* - a string to be entered in the text field
1028
-
1029
- *desc* - a string containing a message or description intended to appear in the log and/or report output
1030
-
1031
- *skip_value_check* (Optional, default is false). Set to true to prevent the built-in verification
1032
- that the text field actually contains the value entered. Useful when application reformats
1033
- or otherwise edits the input string.
1034
-
1035
- _Example_
1036
-
1037
- set_text_field(browser, :name, /thisTextfield/, 'The text to enter')
1038
-
1039
- =end
1040
-
1041
- def set_text_field(browser, how, what, value, desc = '', skip_value_check = false)
1042
- #TODO: fix this to handle Safari password field
1043
- msg = "Set textfield #{how}='#{what}' to '#{value}'"
1044
- msg << " #{desc}" if desc.length > 0
1045
- msg << " (Skip value check)" if skip_value_check
1046
- if browser.text_field(how, what).exists?
1047
- tf = browser.text_field(how, what)
1048
- debug_to_log("#{tf.inspect}")
1049
- if validate(browser, @myName, __LINE__)
1050
- tf.set(value)
1051
- if validate(browser, @myName, __LINE__)
1052
- if tf.value == value
1053
- passed_to_log(msg)
1054
- true
1055
- elsif skip_value_check
1056
- passed_to_log(msg)
1057
- true
1058
- else
1059
- failed_to_log("#{msg}: Found:'#{tf.value}'.")
1060
- end
1061
- end
1062
- end
1063
- else
1064
- failed_to_log("Textfield #{how}='#{what}' not found to set to '#{value}''")
1065
- end
1066
- rescue
1067
- failed_to_log("Unable to '#{msg}': '#{$!}'")
1068
- end
1069
-
1070
- alias set_textfield set_text_field
1071
-
1072
- def set_textfield_by_name(browser, name, value, desc = '', skip_value_check = false)
1073
- if browser.text_field(:name, name).exists?
1074
- tf = browser.text_field(:name, name)
1075
- # Workaround because browser.text_field doesn't work for password fields in Safari
1076
- elsif @browserAbbrev.eql?("S")
1077
- tf = browser.password(:name, name)
1078
- end
1079
- if tf.exists?
1080
- if validate(browser, @myName, __LINE__)
1081
- tf.set(value)
1082
- if validate(browser, @myName, __LINE__)
1083
- if tf.value == value
1084
- passed_to_log("Set textfield name='#{name}' to '#{value}' #{desc}")
1085
- true
1086
- elsif skip_value_check
1087
- passed_to_log("Set textfield name='#{name}' to '#{value}' #{desc} (skip value check)")
1088
- true
1089
- else
1090
- failed_to_log("Set textfield name='#{name}' to '#{value}': Found:'#{tf.value}'. #{desc} (#{__LINE__})")
1091
- end
1092
- end
1093
- end
1094
- else
1095
- failed_to_log("Textfield name='#{name}' not found to set to '#{value}'. #{desc} (#{__LINE__})")
1096
- end
1097
- rescue
1098
- failed_to_log("Textfield name='#{name}' could not be set to '#{value}': '#{$!}'. #{desc} (#{__LINE__})")
1099
- end
1100
-
1101
- =begin rdoc
1102
- :category: A_rdoc_test
1103
- Enter a string into a text field element identified by the value in its id attribute.
1104
-
1105
- _Parameters_::
1106
-
1107
- *browser* - a reference to the browser window to be tested
1108
-
1109
- *id* - a string or a regular expression to be found in the id attribute that uniquely identifies the element.
1110
-
1111
- *value* - a string to be entered in the text field
1112
-
1113
- *desc* - a string containing a message or description intended to appear in the log and/or report output
1114
-
1115
- *skip_value_check* (Optional, default is false). Set to true to prevent the built-in verification
1116
- that the text field actually contains the value entered. Useful when application reformats
1117
- or otherwise edits the input string.
1118
-
1119
- _Example_
1120
-
1121
- set_text_field_by_id(browser, /thisTextfield/, 'The text to enter')
1122
-
1123
- =end
1124
-
1125
- def set_textfield_by_id(browser, id, value, desc = '', skip_value_check = false)
1126
- set_text_field(browser, :id, id, value, desc, skip_value_check)
1127
- end
1128
-
1129
- def set_textfield_by_title(browser, title, value, desc = '', skip_value_check = false)
1130
- set_text_field(browser, :title, title, value, desc, skip_value_check)
1131
- end
1132
-
1133
- def set_textfield_by_class(browser, strg, value, desc = '', skip_value_check = false)
1134
- set_text_field(browser, :class, strg, value, desc, skip_value_check)
1135
- end
1136
-
1137
- =begin rdoc
1138
- :category: A_rdoc_test
1139
- Enter a string into a text field element identified by an attribute type and a value.
1140
- After the entry the value in the text field is validated against the *valid_value*. Use when the application reformats
1141
- or performs edits on the input value.
1142
-
1143
- _Parameters_::
1144
-
1145
- *browser* - a reference to the browser window to be tested
1146
-
1147
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
1148
- Common values: :text, :id, :title, :name, :class, :href (:link only)
1149
-
1150
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
1151
-
1152
- *value* - a string to be entered in the text field
1153
-
1154
- *desc* - a string containing a message or description intended to appear in the log and/or report output
1155
-
1156
- *valid_value* (Optional, default is nil). Set to the expected value
1157
-
1158
- _Example_
1159
-
1160
- set_text_field_and_validate(browser, :id, /AmountTendered/, '7500', 'Dollar formatting', '$7,500.00')
1161
-
1162
- =end
1163
-
1164
- def set_text_field_and_validate(browser, how, what, value, desc = '', valid_value = nil)
1165
- #NOTE: use when value and valid_value differ as with dollar reformatting
1166
- if set_text_field(browser, how, what, value, desc, true)
1167
- expected = valid_value ? valid_value : value
1168
- validate_textfield_value(browser, how, what, expected)
1169
- end
1170
- rescue
1171
- failed_to_log("Unable to '#{msg}': '#{$!}'")
1172
- end
1173
-
1174
- =begin rdoc
1175
- :category: A_rdoc_test
1176
- Allows a generic way to fire browser or javascript events on page elements.
1177
- Raises UnknownObjectException if the object is not found or ObjectDisabledException if the object is currently disabled.
1178
- _Parameters_::
1179
-
1180
- *browser* - a reference to the browser window to be tested
1181
-
1182
- *element* - the kind of element to click. Must be one of the elements recognized by Watir.
1183
- Some common values are :link, :button, :image, :div, :span.
1184
-
1185
- *how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
1186
- Common values: :text, :id, :title, :name, :class, :href (:link only)
1187
-
1188
- *what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
1189
-
1190
- *event* - a string indicating the event to be triggered, e.g., 'onMouseOver', 'onClick', and etc.
1191
-
1192
- *desc* - a string containing a message or description intended to appear in the log and/or report output
1193
-
1194
- _Example_
1195
-
1196
- # html for a link element:
1197
- # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
1198
- fire_event(browser, :link, :text, 'Pickaxe', 'onMouseOver')
1199
-
1200
- =end
1201
-
1202
- def fire_event(browser, element, how, what, event, desc = '')
1203
- msg = "#{element.to_s.titlecase}: #{how}=>'#{what}' event:'#{event}'"
1204
- msg1 = "#{element.to_s.titlecase}(#{how}, '#{what}')"
1205
- begin
1206
- case element
1207
- when :link
1208
- browser.link(how, what).fire_event(event)
1209
- when :button
1210
- browser.button(how, what).fire_event(event)
1211
- when :image
1212
- browser.image(how, what).fire_event(event)
1213
- when :span
1214
- browser.span(how, what).fire_event(event)
1215
- when :div
1216
- browser.div(how, what).fire_event(event)
1217
- else
1218
- browser.element(how, what).fire_event(event)
1219
- end
1220
- rescue => e
1221
- if not rescue_me(e, __method__, "browser(#{msg1}).fire_event('#{event}')", "#{browser.class}")
1222
- raise e
1223
- end
1224
- end
1225
- if validate(browser, @myName, __LINE__)
1226
- passed_to_log("Fire event: #{msg}. #{desc}")
1227
- true
1228
- end
1229
- rescue
1230
- failed_to_log("Unable to fire event: #{msg}. '#{$!}' #{desc}")
1231
- end
1232
-
1233
- def fire_event_on_link_by_text(browser, strg, event = 'onclick', desc = '')
1234
- fire_event(browser, :link, :text, strg, event, desc)
1235
- end
1236
-
1237
- alias fire_event_text fire_event_on_link_by_text
1238
- alias fire_event_by_text fire_event_on_link_by_text
1239
-
1240
- def fire_event_on_link_by_id(browser, strg, event = 'onclick', desc = '')
1241
- fire_event(browser, :link, :id, strg, event, desc)
1242
- end
1243
-
1244
- alias fire_event_id fire_event_on_link_by_id
1245
- alias fire_event_by_id fire_event_on_link_by_id
1246
-
1247
- def fire_event_on_image_by_src(browser, strg, event = 'onclick', desc = '')
1248
- fire_event(browser, :img, :src, strg, event, desc)
1249
- end
1250
-
1251
- alias fire_event_src fire_event_on_image_by_src
1252
- alias fire_event_image_by_src fire_event_on_image_by_src
1253
-
1254
-
1255
- end