awetestlib 0.1.29pre4-x86-mingw32 → 0.1.29-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +123 -123
- data/bin/awetestlib-android-setup.rb +28 -28
- data/bin/awetestlib-cucumber-setup.rb +30 -30
- data/bin/awetestlib-driver-setup.rb +22 -22
- data/bin/awetestlib-helpers.rb +42 -42
- data/bin/awetestlib-mobile-app-setup.rb +32 -32
- data/bin/awetestlib-netbeans-setup.rb +60 -60
- data/bin/awetestlib-regression-setup.rb +30 -30
- data/bin/awetestlib-rubymine-setup.rb +45 -45
- data/lib/awetestlib/logging.rb +366 -366
- data/lib/awetestlib/regression/browser.rb +1378 -1385
- data/lib/awetestlib/regression/drag_and_drop.rb +3 -4
- data/lib/awetestlib/regression/runner.rb +2 -3
- data/lib/awetestlib/regression/tables.rb +9 -17
- data/lib/awetestlib/regression/user_input.rb +1 -1
- data/lib/awetestlib/regression/utilities.rb +24 -82
- data/lib/awetestlib/regression/validations.rb +1075 -1094
- data/lib/version.rb +2 -2
- data/netbeans_setup.md +6 -6
- data/rubymine_setup.md +5 -5
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +354 -354
- metadata +8 -26
- data/images/netbeans1.jpg +0 -0
- data/images/netbeans2.jpg +0 -0
- data/images/netbeans3.jpg +0 -0
- data/images/netbeans4.jpg +0 -0
- data/images/netbeans5.jpg +0 -0
- data/images/rubymine1.jpg +0 -0
- data/images/rubymine2.jpg +0 -0
- data/images/rubymine3.jpg +0 -0
- data/images/rubymine4.jpg +0 -0
- data/images/scripting1.png +0 -0
- data/images/scripting2.png +0 -0
- data/images/scripting3.png +0 -0
- data/images/scripting4.png +0 -0
- data/test/demo_wwd.rb +0 -7
@@ -1,1385 +1,1378 @@
|
|
1
|
-
module Awetestlib
|
2
|
-
# Awetest DSL for browser based testing.
|
3
|
-
module Regression
|
4
|
-
# Methods to manage browser windows: open, close, attach, verify health, and clean up.
|
5
|
-
module Browser
|
6
|
-
|
7
|
-
#def run #DO WE NEED? Use this method to tell user they need to create a run method?
|
8
|
-
## Not here in any case.
|
9
|
-
# setup
|
10
|
-
# set_script_variables
|
11
|
-
# run_test
|
12
|
-
#rescue
|
13
|
-
# fatal_to_log("(#{__LINE__}) #{$!}")
|
14
|
-
# browser.close
|
15
|
-
# raise
|
16
|
-
#end
|
17
|
-
|
18
|
-
# @!group Browser
|
19
|
-
|
20
|
-
# @note webdriver specific - still work in progress
|
21
|
-
def go_to_wd_url(browser, url)
|
22
|
-
|
23
|
-
Watir::Browser.class_eval do
|
24
|
-
def goto(uri)
|
25
|
-
uri = "http://#{uri}" unless uri =~ URI.regexp
|
26
|
-
@driver.navigate.to uri
|
27
|
-
run_checkers
|
28
|
-
end
|
29
|
-
end
|
30
|
-
browser.goto(url)
|
31
|
-
|
32
|
-
#in basic_auth1 edit:
|
33
|
-
#a = Thread.new {
|
34
|
-
# goto_wd_url(browser, @myURL)
|
35
|
-
# }
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
alias goto_wd_url go_to_wd_url
|
40
|
-
|
41
|
-
# Open a browser based on the command line parameters that identify the browser and
|
42
|
-
# version to use for the test.
|
43
|
-
# @
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# @
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@myBrowser
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# @
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# @
|
132
|
-
# @param [
|
133
|
-
# @param [
|
134
|
-
# @
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
tmpbrowser
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
browser
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
#
|
157
|
-
#
|
158
|
-
# tmpbrowser
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
# browser
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
# @param [
|
193
|
-
# @param [
|
194
|
-
# @
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
popup
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
# @!
|
231
|
-
|
232
|
-
#
|
233
|
-
|
234
|
-
#
|
235
|
-
# @param [
|
236
|
-
# @
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
myURL
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
#
|
266
|
-
# @param [
|
267
|
-
# @param [String]
|
268
|
-
# @param [
|
269
|
-
#
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
message_to_report ("
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
@ai.
|
292
|
-
@ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:
|
293
|
-
@ai.
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
#
|
308
|
-
# @param [
|
309
|
-
# @param [String]
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
# @!
|
321
|
-
|
322
|
-
#
|
323
|
-
|
324
|
-
#
|
325
|
-
#
|
326
|
-
# @param [
|
327
|
-
#
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
msg
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
cnt1
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
cnt1
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
pid
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
cnt1
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
pid
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
#
|
403
|
-
#
|
404
|
-
# @param [
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
browser
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
browser.
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
# @!
|
444
|
-
|
445
|
-
#
|
446
|
-
|
447
|
-
#
|
448
|
-
#
|
449
|
-
# @
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
rtrn
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
#
|
481
|
-
#
|
482
|
-
# @param [
|
483
|
-
# @param [String]
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
myHandle
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
end
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
#
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
browser.close
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
browser.close
|
548
|
-
end
|
549
|
-
when '
|
550
|
-
if is_browser?(browser)
|
551
|
-
url = browser.url
|
552
|
-
title = browser.title
|
553
|
-
debug_to_log("
|
554
|
-
debug_to_log("
|
555
|
-
debug_to_log("Closing browser: #{where} (#{lnbr})")
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
#
|
623
|
-
#
|
624
|
-
#
|
625
|
-
#
|
626
|
-
#
|
627
|
-
#
|
628
|
-
#
|
629
|
-
#
|
630
|
-
#
|
631
|
-
#
|
632
|
-
#
|
633
|
-
#
|
634
|
-
#
|
635
|
-
#
|
636
|
-
#
|
637
|
-
#
|
638
|
-
#
|
639
|
-
#
|
640
|
-
#
|
641
|
-
#
|
642
|
-
# if
|
643
|
-
#
|
644
|
-
#
|
645
|
-
#
|
646
|
-
#
|
647
|
-
#
|
648
|
-
#
|
649
|
-
#
|
650
|
-
#
|
651
|
-
#
|
652
|
-
#
|
653
|
-
#
|
654
|
-
#
|
655
|
-
#
|
656
|
-
#
|
657
|
-
#
|
658
|
-
#
|
659
|
-
#
|
660
|
-
#
|
661
|
-
#
|
662
|
-
#
|
663
|
-
#
|
664
|
-
#
|
665
|
-
#
|
666
|
-
#
|
667
|
-
#
|
668
|
-
#
|
669
|
-
#
|
670
|
-
#
|
671
|
-
#
|
672
|
-
#
|
673
|
-
#
|
674
|
-
#
|
675
|
-
#
|
676
|
-
#
|
677
|
-
#
|
678
|
-
#
|
679
|
-
#
|
680
|
-
#
|
681
|
-
#
|
682
|
-
|
683
|
-
#
|
684
|
-
#
|
685
|
-
#
|
686
|
-
#
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
#
|
720
|
-
# @param [
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
# Close
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
#
|
756
|
-
# @param [
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
debug_to_log("#{msg}
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
#
|
822
|
-
#
|
823
|
-
|
824
|
-
#
|
825
|
-
|
826
|
-
#
|
827
|
-
# @
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
#
|
884
|
-
#
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
when '
|
1020
|
-
case title
|
1021
|
-
when "
|
1022
|
-
new_title = "
|
1023
|
-
when "The page at"
|
1024
|
-
new_title = "
|
1025
|
-
end
|
1026
|
-
when '
|
1027
|
-
case title
|
1028
|
-
when "Message from webpage"
|
1029
|
-
new_title = "Microsoft Internet Explorer"
|
1030
|
-
when "The page at"
|
1031
|
-
new_title = "
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
case title
|
1035
|
-
when "
|
1036
|
-
new_title = "
|
1037
|
-
when "The page at"
|
1038
|
-
new_title = "
|
1039
|
-
end
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
end
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
when
|
1061
|
-
new_title = '
|
1062
|
-
when "
|
1063
|
-
new_title = 'The page at'
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
@
|
1086
|
-
@
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
@browserAppInfo
|
1093
|
-
|
1094
|
-
|
1095
|
-
@
|
1096
|
-
@
|
1097
|
-
@
|
1098
|
-
@browserAppInfo
|
1099
|
-
|
1100
|
-
|
1101
|
-
@
|
1102
|
-
@
|
1103
|
-
@
|
1104
|
-
@browserAppInfo
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
#
|
1123
|
-
|
1124
|
-
#
|
1125
|
-
#
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
#
|
1143
|
-
|
1144
|
-
#
|
1145
|
-
#
|
1146
|
-
#
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
#
|
1333
|
-
|
1334
|
-
#
|
1335
|
-
|
1336
|
-
#
|
1337
|
-
# @
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
#
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
# Returns a reference to a new browser window identified by its *:
|
1352
|
-
# which can then be passed to methods that require a *browser* parameter. Calls attach_browser().
|
1353
|
-
# @param (see #attach_browser_by_url)
|
1354
|
-
def
|
1355
|
-
attach_popup(browser, :
|
1356
|
-
end
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
#
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
# @!endgroup Backward
|
1380
|
-
|
1381
|
-
|
1382
|
-
end
|
1383
|
-
end
|
1384
|
-
end
|
1385
|
-
|
1
|
+
module Awetestlib
|
2
|
+
# Awetest DSL for browser based testing.
|
3
|
+
module Regression
|
4
|
+
# Methods to manage browser windows: open, close, attach, verify health, and clean up.
|
5
|
+
module Browser
|
6
|
+
|
7
|
+
#def run #DO WE NEED? Use this method to tell user they need to create a run method?
|
8
|
+
## Not here in any case.
|
9
|
+
# setup
|
10
|
+
# set_script_variables
|
11
|
+
# run_test
|
12
|
+
#rescue
|
13
|
+
# fatal_to_log("(#{__LINE__}) #{$!}")
|
14
|
+
# browser.close
|
15
|
+
# raise
|
16
|
+
#end
|
17
|
+
|
18
|
+
# @!group Browser
|
19
|
+
|
20
|
+
# @note webdriver specific - still work in progress
|
21
|
+
def go_to_wd_url(browser, url)
|
22
|
+
|
23
|
+
Watir::Browser.class_eval do
|
24
|
+
def goto(uri)
|
25
|
+
uri = "http://#{uri}" unless uri =~ URI.regexp
|
26
|
+
@driver.navigate.to uri
|
27
|
+
run_checkers
|
28
|
+
end
|
29
|
+
end
|
30
|
+
browser.goto(url)
|
31
|
+
|
32
|
+
#in basic_auth1 edit:
|
33
|
+
#a = Thread.new {
|
34
|
+
# goto_wd_url(browser, @myURL)
|
35
|
+
# }
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
alias goto_wd_url go_to_wd_url
|
40
|
+
|
41
|
+
# Open a browser based on the command line parameters that identify the browser and
|
42
|
+
# version to use for the test.
|
43
|
+
# @example
|
44
|
+
# browser = open_browser('www.google.com')
|
45
|
+
# @param [String, Regexp] url When provided, the browser will go to this url.
|
46
|
+
# @return [Watir::Browser]
|
47
|
+
def open_browser(url = nil)
|
48
|
+
message_to_report("Opening browser: #{@targetBrowser.name}")
|
49
|
+
case @targetBrowser.abbrev
|
50
|
+
when 'IE'
|
51
|
+
@myBrowser = open_ie
|
52
|
+
if @myBrowser.class.to_s == "Watir::IE"
|
53
|
+
@myHwnd = @myBrowser.hwnd
|
54
|
+
end
|
55
|
+
when 'FF'
|
56
|
+
@myBrowser = open_ff_for_version
|
57
|
+
when 'S'
|
58
|
+
aBrowser = Watir::Browser.new :safari
|
59
|
+
@myBrowser = aBrowser
|
60
|
+
when 'C', 'GC'
|
61
|
+
@myBrowser = open_chrome
|
62
|
+
else
|
63
|
+
raise "Unsupported browser: #{@targetBrowser.name}"
|
64
|
+
end
|
65
|
+
if url
|
66
|
+
go_to_url(@myBrowser, url)
|
67
|
+
end
|
68
|
+
@myBrowser
|
69
|
+
end
|
70
|
+
|
71
|
+
# Open IE (Internet Explorer) browser instance.
|
72
|
+
# If global variable $watir_script is set to true in the first line of the script,
|
73
|
+
# classic Watir will be used to drive the browser,
|
74
|
+
# otherwise Watir Webdriver will be used.
|
75
|
+
# @return [Watir::Browser]
|
76
|
+
def open_ie
|
77
|
+
if $watir_script
|
78
|
+
browser = Watir::IE.new
|
79
|
+
else
|
80
|
+
browser = Watir::Browser.new :ie
|
81
|
+
end
|
82
|
+
browser
|
83
|
+
end
|
84
|
+
|
85
|
+
# Open FF (Firefox) browser instance.
|
86
|
+
# @param [Fixnum] version A number designating the version of the browser to be opened.
|
87
|
+
# @return [Watir::Browser, Firewatir::Browser]
|
88
|
+
# Returns Firewatir::Browser if target browser is Firefox version less than 4.0
|
89
|
+
def open_ff_for_version(version = @targetVersion)
|
90
|
+
browser = Watir::Browser.new :firefox
|
91
|
+
end
|
92
|
+
|
93
|
+
# Open FF (Firefox) browser instance under FireWatir.
|
94
|
+
# @return [Firewatir::Browser]
|
95
|
+
def open_ff
|
96
|
+
# Watir::Browser.default = 'firefox'
|
97
|
+
browser = Watir::Browser.new :firefox
|
98
|
+
end
|
99
|
+
|
100
|
+
# Open GC (Google Chrome) browser instance.
|
101
|
+
# @return [Watir::Browser] Browser is Google Chrome.
|
102
|
+
def open_chrome
|
103
|
+
browser = Watir::Browser.new(:chrome)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Instruct browser to navigate to a specific URL
|
107
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
108
|
+
# @param [String] url When provided, the browser will go to this url.
|
109
|
+
# and the instance variable @myURL will be set to this value.
|
110
|
+
# @return [Boolean] True when navigation to url succeeds.
|
111
|
+
def go_to_url(browser, url = nil)
|
112
|
+
if url
|
113
|
+
@myURL = url
|
114
|
+
end
|
115
|
+
message_to_report("URL: #{@myURL}")
|
116
|
+
browser.goto(@myURL)
|
117
|
+
true
|
118
|
+
rescue
|
119
|
+
fatal_to_log("Unable to navigate to '#{@myURL}': '#{$!}'")
|
120
|
+
end
|
121
|
+
|
122
|
+
# Return a reference to a browser window. Used to attach a browser window to a variable
|
123
|
+
# which can then be passed to methods that require a *browser* parameter.
|
124
|
+
# @example
|
125
|
+
# mainwindow = open_browser('www.google.com')
|
126
|
+
# click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
|
127
|
+
# popup = attach_browser(mainwindow, :url, '[url of new window]') #*or*
|
128
|
+
# popup = attach_browser(mainwindow, :title, '[title of new window]')
|
129
|
+
# @todo Update to work with webdriver for IE.
|
130
|
+
# @param [Watir::Browser] browser A reference to the current browser window.
|
131
|
+
# @param [Symbol] how The element attribute used to identify the window: *:title* or :url.
|
132
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
133
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
134
|
+
# @return [Watir::Browser] Internet Explorer
|
135
|
+
def attach_browser(browser, how, what, desc = '')
|
136
|
+
debug_to_log("Attaching browser window :#{how}=>'#{what}' #{desc}")
|
137
|
+
uri_decoded_pattern = ::URI.encode(what.to_s.gsub('(?-mix:', '').gsub(')', ''))
|
138
|
+
|
139
|
+
if $watir_script
|
140
|
+
tmpbrowser = Watir::IE.attach(how, what)
|
141
|
+
browser.visible = true
|
142
|
+
if tmpbrowser
|
143
|
+
tmpbrowser.visible = true
|
144
|
+
tmpbrowser.speed = :fast
|
145
|
+
else
|
146
|
+
raise "Browser window :#{how}=>'#{what}' has at least one doc not in completed ready state."
|
147
|
+
end
|
148
|
+
else
|
149
|
+
browser.driver.switch_to.window(browser.driver.window_handles[0])
|
150
|
+
browser.window(how, /#{uri_decoded_pattern}/).use
|
151
|
+
tmpbrowser = browser
|
152
|
+
end
|
153
|
+
|
154
|
+
# case @browserAbbrev
|
155
|
+
# when 'IE'
|
156
|
+
# tmpbrowser = Watir::IE.attach(how, what)
|
157
|
+
# browser.visible = true
|
158
|
+
# if tmpbrowser
|
159
|
+
# tmpbrowser.visible = true
|
160
|
+
# tmpbrowser.speed = :fast
|
161
|
+
# else
|
162
|
+
# raise "Browser window :#{how}=>'#{what}' has at least one doc not in completed ready state."
|
163
|
+
# end
|
164
|
+
# when 'FF'
|
165
|
+
# #TODO: This may be dependent on Firefox version if webdriver doesn't support 3.6.17 and below
|
166
|
+
# browser.driver.switch_to.window(browser.driver.window_handles[0])
|
167
|
+
# browser.window(how, /#{uri_decoded_pattern}/).use
|
168
|
+
# tmpbrowser = browser
|
169
|
+
# when 'S'
|
170
|
+
# Watir::Safari.attach(how, what)
|
171
|
+
# tmpbrowser = browser
|
172
|
+
# when 'C', 'GC'
|
173
|
+
# browser.window(how, /#{uri_decoded_pattern}/).use
|
174
|
+
# tmpbrowser = browser
|
175
|
+
# end
|
176
|
+
|
177
|
+
|
178
|
+
debug_to_log("#{__method__}: tmpbrowser:#{tmpbrowser.inspect}")
|
179
|
+
tmpbrowser
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
# Returns a reference to a new browser window. Used to attach a new browser window to a variable
|
184
|
+
# which can then be passed to methods that require a *browser* parameter. Calls attach_browser().
|
185
|
+
# @example
|
186
|
+
# mainwindow = open_browser('www.google.com')
|
187
|
+
# click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
|
188
|
+
# popup = attach_popup(mainwindow, :url, '[url of new window]') *or*
|
189
|
+
# popup = attach_popup(mainwindow, :title, '[title of new window]')
|
190
|
+
# @param [Watir::Browser] browser A reference to the current browser window.
|
191
|
+
# @param [Symbol] how The element attribute used to identify the window: *:title* or :url.
|
192
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
193
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
194
|
+
# @return [Watir::Browser] The new browser window.
|
195
|
+
def attach_popup(browser, how, what, desc = '')
|
196
|
+
msg = "Attach popup :#{how}=>'#{what}'. #{desc}"
|
197
|
+
popup = attach_browser(browser, how, what, desc)
|
198
|
+
sleep_for(1)
|
199
|
+
debug_to_log("#{popup.inspect}")
|
200
|
+
if is_browser?(popup)
|
201
|
+
title = popup.title
|
202
|
+
passed_to_log("#{msg} title='#{title}'")
|
203
|
+
return popup
|
204
|
+
else
|
205
|
+
failed_to_log(msg)
|
206
|
+
end
|
207
|
+
rescue
|
208
|
+
failed_to_log("Unable to attach popup :#{how}=>'#{what}'. #{desc} '#{$!}' (#{__LINE__})")
|
209
|
+
end
|
210
|
+
|
211
|
+
# Locate and close instances of IE browsers
|
212
|
+
def find_other_browsers
|
213
|
+
cnt = 0
|
214
|
+
if @targetBrowser.abbrev == 'IE'
|
215
|
+
Watir::IE.each do |ie|
|
216
|
+
debug_to_log("#{ie.inspect}")
|
217
|
+
ie.close()
|
218
|
+
cnt = cnt + 1
|
219
|
+
end
|
220
|
+
end
|
221
|
+
debug_to_log("Found #{cnt} IE browser(s).")
|
222
|
+
return cnt
|
223
|
+
rescue
|
224
|
+
error_to_log("#{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}", __LINE__)
|
225
|
+
return 0
|
226
|
+
end
|
227
|
+
|
228
|
+
# @!endgroup Browser
|
229
|
+
|
230
|
+
# @!group Login
|
231
|
+
|
232
|
+
# Simple login method
|
233
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
234
|
+
# @param [String] user Login ID for the user.
|
235
|
+
# @param [String] password Password for the user.
|
236
|
+
# @return [Boolean] True if login succeeds.
|
237
|
+
def login(browser, user, password)
|
238
|
+
#TODO: Needs to be more flexible about finding login id and password textfields
|
239
|
+
#TODO: Parameterize url and remove references to environment
|
240
|
+
myURL = @myAppEnv.url
|
241
|
+
runenv = @myAppEnv.nodename
|
242
|
+
message_tolog("URL: #{myURL}") if @myAppEnv
|
243
|
+
message_tolog("Beginning login: User: #{user} Environment: #{@myAppEnv.nodename}") if @myAppEnv
|
244
|
+
if validate(browser, @myName, __LINE__)
|
245
|
+
browser.goto(@myAppEnv.url)
|
246
|
+
if validate(browser, @myName)
|
247
|
+
set_textfield_by_name(browser, 'loginId', user)
|
248
|
+
set_textfield_by_name(browser, 'password', password)
|
249
|
+
click_button_by_value(browser, 'Login')
|
250
|
+
if validate(browser, @myName)
|
251
|
+
passed_to_log("Login successful.")
|
252
|
+
true
|
253
|
+
end
|
254
|
+
else
|
255
|
+
failed_to_log("Unable to login to application: '#{$!}'")
|
256
|
+
#screen_capture( "#{@myRoot}/screens/#{myName}_#{@runid}_#{__LINE__.to_s}_#{Time.new.to_f.to_s}.jpg")
|
257
|
+
end
|
258
|
+
end
|
259
|
+
rescue
|
260
|
+
failed_to_log("Unable to login to application: '#{$!}'")
|
261
|
+
end
|
262
|
+
|
263
|
+
# Logon to webpage using Basic Authorization type of logon. Uses AutoIt
|
264
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
265
|
+
# @param [String] user Login ID for the user.
|
266
|
+
# @param [String] password Password for the user.
|
267
|
+
# @param [String] url The URL to log on to.
|
268
|
+
# @param [Boolean] bypass_validate When set to true, the call to validate(),
|
269
|
+
# which checks the health of the browser, is skipped..
|
270
|
+
def basic_auth(browser, user, password, url, bypass_validate = false)
|
271
|
+
mark_testlevel("Basic Authorization Login", 0)
|
272
|
+
|
273
|
+
message_to_report ("Login: #{user}")
|
274
|
+
message_to_report ("URL: #{url}")
|
275
|
+
message_to_report ("Password: #{password}")
|
276
|
+
|
277
|
+
@login_title = "Connect to"
|
278
|
+
|
279
|
+
a = Thread.new {
|
280
|
+
browser.goto(url)
|
281
|
+
}
|
282
|
+
|
283
|
+
sleep_for(2)
|
284
|
+
message_to_log("#{@login_title}...")
|
285
|
+
|
286
|
+
if (@ai.WinWait(@login_title, "", 90) > 0)
|
287
|
+
win_title = @ai.WinGetTitle(@login_title)
|
288
|
+
debug_to_log("Basic Auth Login window appeared: '#{win_title}'")
|
289
|
+
@ai.WinActivate(@login_title)
|
290
|
+
@ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:2]", '!u')
|
291
|
+
@ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:2]", user, 1)
|
292
|
+
@ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:3]", password.gsub(/!/, '{!}'), 1)
|
293
|
+
@ai.ControlClick(@login_title, "", '[CLASS:Button; INSTANCE:1]')
|
294
|
+
else
|
295
|
+
debug_to_log("Basic Auth Login window did not appear.")
|
296
|
+
end
|
297
|
+
a.join
|
298
|
+
|
299
|
+
validate(browser, @myName) unless bypass_validate
|
300
|
+
|
301
|
+
message_to_report("URL: [#{browser.url}] User: [#{user}]")
|
302
|
+
|
303
|
+
end
|
304
|
+
|
305
|
+
# Provide an authorization token or passcode in a specified text field element identified by its *:id* attribute.
|
306
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
307
|
+
# @param [String] role Usually a user role designation ('Administrator', 'User', etc.)
|
308
|
+
# @param [String] token Authentification token required by logon process.
|
309
|
+
# @param [String/Regexp] id Value of the *:id* attribute of the text field that will receive the *token*.
|
310
|
+
def token_auth(browser, role, token, id = 'token_pass')
|
311
|
+
set_textfield_by_id(browser, id, token)
|
312
|
+
click_button_by_value(browser, 'Continue')
|
313
|
+
if validate_text(browser, 'The requested page requires authentication\.\s*Please enter your Passcode below', nil, true)
|
314
|
+
bail_out(browser, __LINE__, "Token authorization failed on '#{token}'")
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
# @!endgroup Logon
|
319
|
+
|
320
|
+
# @!group Error Handling
|
321
|
+
|
322
|
+
# Exit more or less gracefully from script when errors are too severe to continue.
|
323
|
+
# Normally not called in a test script or project library.
|
324
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
325
|
+
# @param [Fixnum] lnbr Line number in calling script.
|
326
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
327
|
+
#
|
328
|
+
def bail_out(browser, lnbr, desc)
|
329
|
+
ts = Time.new
|
330
|
+
msg = "Bailing out at util line #{lnbr} #{ts} " + desc
|
331
|
+
puts "#{msg}"
|
332
|
+
fatal_to_log(msg, lnbr)
|
333
|
+
debug_to_log(dump_caller(lnbr))
|
334
|
+
if is_browser?(browser)
|
335
|
+
if @browserAbbrev == 'IE'
|
336
|
+
hwnd = browser.hwnd
|
337
|
+
kill_browser(hwnd, lnbr, browser)
|
338
|
+
raise(RuntimeError, msg, caller)
|
339
|
+
elsif @browserAbbrev == 'FF'
|
340
|
+
debug_to_log("#{browser.inspect}")
|
341
|
+
debug_to_log("#{browser.to_s}")
|
342
|
+
raise(RuntimeError, msg, caller)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
@status = 'bailout'
|
346
|
+
raise(RuntimeError, msg, caller)
|
347
|
+
end
|
348
|
+
|
349
|
+
|
350
|
+
# Check for the presence of IE browser instances.
|
351
|
+
# @return [Fixnum] The number of IE browser instances encountered.
|
352
|
+
def check_for_other_browsers
|
353
|
+
cnt1 = find_other_browsers
|
354
|
+
cnt2 = Watir::Process.count 'iexplore.exe'
|
355
|
+
debug_to_log("check_for_other_browsers: cnt1: #{cnt1} cnt2: #{cnt2}")
|
356
|
+
rescue
|
357
|
+
error_to_log("#{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}")
|
358
|
+
end
|
359
|
+
|
360
|
+
# Check for the presence of IE browser instances and close all that are found.
|
361
|
+
def check_for_and_clear_other_browsers
|
362
|
+
if @targetBrowser.abbrev == 'IE'
|
363
|
+
debug_to_log("#{__method__}:")
|
364
|
+
cnt1 = find_other_browsers
|
365
|
+
cnt2 = Watir::IE.process_count
|
366
|
+
debug_to_log("#{__method__}: cnt1: #{cnt1} cnt2: #{cnt2}")
|
367
|
+
begin
|
368
|
+
Watir::IE.each do |ie|
|
369
|
+
pid = Watir::IE::Process.process_id_from_hwnd(ie.hwnd)
|
370
|
+
debug_to_log("#{__method__}: Killing browser process: hwnd #{ie.hwnd} pid #{pid} title '#{ie.title}' (#{__LINE__})")
|
371
|
+
do_taskkill(INFO, pid)
|
372
|
+
sleep_for(10)
|
373
|
+
end
|
374
|
+
#Watir::IE.close_all()
|
375
|
+
rescue
|
376
|
+
debug_to_log("#{__method__}: #{$!} (#{__LINE__})")
|
377
|
+
end
|
378
|
+
sleep(3)
|
379
|
+
cnt1 = find_other_browsers
|
380
|
+
cnt2 = Watir::IE.process_count
|
381
|
+
if cnt1 > 0 or cnt2 > 0
|
382
|
+
debug_to_log("#{__method__}:cnt1: #{cnt1} cnt2: #{cnt2}")
|
383
|
+
begin
|
384
|
+
Watir::IE.each do |ie|
|
385
|
+
pid = Watir::IE::Process.process_id_from_hwnd(ie.hwnd)
|
386
|
+
debug_to_log("#{__method__}: Killing browser process: hwnd #{ie.hwnd} pid #{pid} title '#{ie.title}' (#{__LINE__})")
|
387
|
+
do_taskkill(INFO, pid)
|
388
|
+
sleep_for(10)
|
389
|
+
end
|
390
|
+
#Watir::IE.close_all()
|
391
|
+
rescue
|
392
|
+
debug_to_log("#{__method__}:#{$!} (#{__LINE__})")
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
rescue
|
397
|
+
error_to_log("#{__method__}: #{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}")
|
398
|
+
end
|
399
|
+
|
400
|
+
# Force browser instance to close, one way or the other.
|
401
|
+
# Instance is identified by *hwnd*, the Windows OS handle for the process.
|
402
|
+
# @param [String] hwnd The value for the window handle for the browser process.
|
403
|
+
# @param [Fixnum] lnbr Line number in calling script.
|
404
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be closed.
|
405
|
+
def kill_browser(hwnd, lnbr, browser = nil, doflag = false)
|
406
|
+
# TODO Firefox
|
407
|
+
logit = false
|
408
|
+
if @browserAbbrev == 'FF'
|
409
|
+
if is_browser?(browser) # and browser.url.length > 1
|
410
|
+
logit = true
|
411
|
+
here = __LINE__
|
412
|
+
url = browser.url
|
413
|
+
#capture_screen(browser, Time.new.to_f) if @screenCaptureOn
|
414
|
+
browser.close if url.length > 0
|
415
|
+
@status = 'killbrowser'
|
416
|
+
fatal_to_log("Kill browser called from line #{lnbr}")
|
417
|
+
end
|
418
|
+
elsif hwnd
|
419
|
+
pid = Watir::IE::Process.process_id_from_hwnd(hwnd)
|
420
|
+
if pid and pid > 0 and pid < 538976288
|
421
|
+
if browser.exists?
|
422
|
+
here = __LINE__
|
423
|
+
logit = true
|
424
|
+
url = browser.url
|
425
|
+
#capture_screen(browser, Time.new.to_f) if @screenCaptureOn
|
426
|
+
browser.close
|
427
|
+
sleep(2)
|
428
|
+
if browser.exists?
|
429
|
+
do_taskkill(FATAL, pid)
|
430
|
+
end
|
431
|
+
@status = 'killbrowser'
|
432
|
+
end
|
433
|
+
end
|
434
|
+
if logit
|
435
|
+
debug_to_log("#{@browserName} window hwnd #{hwnd} pid #{pid} #{url} (#{here})")
|
436
|
+
fatal_to_log("Kill browser called from line #{lnbr}")
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
# @!endgroup Error Handling
|
442
|
+
|
443
|
+
# @!group Browser
|
444
|
+
|
445
|
+
# Use enabled_popup and winclicker to determine if there is an active modal popup.
|
446
|
+
# Useful only when no wait action has been invoked.
|
447
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
448
|
+
# @param [String] button The visible name of the button to be clicked to close the popup.
|
449
|
+
# @return [String] containing the window handle of the closed modal popup.
|
450
|
+
def modal_exists?(browser, button = nil)
|
451
|
+
rtrn = nil
|
452
|
+
if @browserAbbrev == 'IE'
|
453
|
+
Timeout::timeout(2) do
|
454
|
+
begin
|
455
|
+
if browser.enabled_popup
|
456
|
+
hwnd = browser.enabled_popup(5)
|
457
|
+
debug_to_log("Modal popup with handle #{hwnd} found. (#{__LINE__})")
|
458
|
+
wc = WinClicker.new
|
459
|
+
wc.makeWindowActive(hwnd)
|
460
|
+
rtrn = wc.getWindowTitle(hwnd)
|
461
|
+
if button
|
462
|
+
wc.clickWindowsButton_hWnd(hwnd, button)
|
463
|
+
end
|
464
|
+
wc = nil
|
465
|
+
end
|
466
|
+
rescue Timeout::Error
|
467
|
+
debug_to_log("No Modal popup found. (#{__LINE__})")
|
468
|
+
return rtrn
|
469
|
+
end
|
470
|
+
return rtrn
|
471
|
+
end
|
472
|
+
rtrn
|
473
|
+
else
|
474
|
+
rtrn
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
# Close a browser window identified by its title.
|
479
|
+
# Uses AutoIt. Windows only.
|
480
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
481
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
482
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
483
|
+
# @param [String] text (optional) The text of the window to be closed. Matched from beginning of string.
|
484
|
+
def close_window_by_title(browser, title, desc = '', text = '')
|
485
|
+
msg = "Window '#{title}':"
|
486
|
+
if @ai.WinWait(title, text, WAIT) > 0
|
487
|
+
passed_to_log("#{msg} appeared. #{desc}")
|
488
|
+
myHandle = @ai.WinGetHandle(title, text)
|
489
|
+
full_text = @ai.WinGetText(title)
|
490
|
+
debug_to_log("#{msg} hwnd: #{myHandle.inspect}")
|
491
|
+
debug_to_log("#{msg} title: '#{title}' text: '#{full_text}'")
|
492
|
+
if @ai.WinClose(title, text) > 0
|
493
|
+
passed_to_log("#{msg} closed successfully. #{desc}")
|
494
|
+
else
|
495
|
+
failed_to_log("#{msg} close failed. (#{__LINE__}) #{desc}")
|
496
|
+
end
|
497
|
+
else
|
498
|
+
failed_to_log("#{msg} did not appear after #{WAIT} seconds. (#{__LINE__}) #{desc}")
|
499
|
+
end
|
500
|
+
rescue
|
501
|
+
failed_to_log("#{msg}: Unable to close: '#{$!}'. (#{__LINE__}) #{desc}")
|
502
|
+
end
|
503
|
+
|
504
|
+
# Closes main browser session. Misnamed. Usually used at end of script to shut down browser.
|
505
|
+
def logout(browser, where = @myName, lnbr = __LINE__)
|
506
|
+
#TODO Firewatir 1.6.5 does not implement .exists for FireWatir::Firefox class
|
507
|
+
debug_to_log("Logging out in #{where} at line #{lnbr}.", lnbr, true)
|
508
|
+
debug_to_log("#{__method__}: browser: #{browser.inspect} (#{__LINE__})")
|
509
|
+
|
510
|
+
if ['FF', 'S'].include?(@browserAbbrev) || browser.exists?
|
511
|
+
case @browserAbbrev
|
512
|
+
when 'FF'
|
513
|
+
if is_browser?(browser)
|
514
|
+
url = browser.url
|
515
|
+
title = browser.title
|
516
|
+
debug_to_log("#{__method__}: Firefox browser url: [#{url}]")
|
517
|
+
debug_to_log("#{__method__}: Firefox browser title: [#{title}]")
|
518
|
+
debug_to_log("#{__method__}: Closing browser: #{where} (#{lnbr})")
|
519
|
+
if url and url.length > 1
|
520
|
+
browser.close
|
521
|
+
else
|
522
|
+
browser = FireWatir::Firefox.attach(:title, title)
|
523
|
+
browser.close
|
524
|
+
end
|
525
|
+
|
526
|
+
end
|
527
|
+
when 'IE'
|
528
|
+
hwnd = browser.hwnd
|
529
|
+
pid = Watir::IE::Process.process_id_from_hwnd(hwnd)
|
530
|
+
debug_to_log("#{__method__}: Closing browser: hwnd #{hwnd} pid #{pid} #{where} (#{lnbr}) (#{__LINE__})")
|
531
|
+
browser.close
|
532
|
+
if browser.exists? and pid > 0 and pid < 538976288 # value of uninitialized memory location
|
533
|
+
debug_to_log("Retry close browser: hwnd #{hwnd} pid #{pid} #{where} #{lnbr} (#{__LINE__})")
|
534
|
+
browser.close
|
535
|
+
end
|
536
|
+
if browser.exists? and pid > 0 and pid < 538976288 # value of uninitialized memory location
|
537
|
+
kill_browser(browser.hwnd, __LINE__, browser)
|
538
|
+
end
|
539
|
+
when 'S'
|
540
|
+
if is_browser?(browser)
|
541
|
+
url = browser.url
|
542
|
+
title = browser.title
|
543
|
+
debug_to_log("Safari browser url: [#{url}]")
|
544
|
+
debug_to_log("Safari browser title: [#{title}]")
|
545
|
+
debug_to_log("Closing browser: #{where} (#{lnbr})")
|
546
|
+
close_modal_s # to close any leftover modal dialogs
|
547
|
+
browser.close
|
548
|
+
end
|
549
|
+
when 'C', 'GC'
|
550
|
+
if is_browser?(browser)
|
551
|
+
url = browser.url
|
552
|
+
title = browser.title
|
553
|
+
debug_to_log("Chrome browser url: [#{url}]")
|
554
|
+
debug_to_log("Chrome browser title: [#{title}]")
|
555
|
+
debug_to_log("Closing browser: #{where} (#{lnbr})")
|
556
|
+
if url and url.length > 1
|
557
|
+
browser.close
|
558
|
+
#else
|
559
|
+
#browser = FireWatir::Firefox.attach(:title, title)
|
560
|
+
#browser.close
|
561
|
+
end
|
562
|
+
|
563
|
+
end
|
564
|
+
else
|
565
|
+
raise "Unsupported browser: '#{@browserAbbrev}'"
|
566
|
+
end
|
567
|
+
end
|
568
|
+
# rescue => e
|
569
|
+
# if not e.is_a?(Vapir::WindowGoneException)
|
570
|
+
# raise e
|
571
|
+
# end
|
572
|
+
end
|
573
|
+
|
574
|
+
# Close a browser popup window. Does not apply to modal popups.
|
575
|
+
# @param [Watir::Browser] popup Reference to the popup to be closed
|
576
|
+
def close_new_window_popup(popup)
|
577
|
+
if is_browser?(popup)
|
578
|
+
url = popup.url
|
579
|
+
debug_to_log("Closing popup '#{url}' ")
|
580
|
+
popup.close
|
581
|
+
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
# Close an HTML panel or division by clicking a link within it identified by the *:text* value of the link.
|
586
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
587
|
+
# @param [Watir::Browser] panel Reference to the panel (usually a div element) to be closed
|
588
|
+
def close_panel_by_text(browser, panel, what = 'Close')
|
589
|
+
if validate(browser, @myName, __LINE__)
|
590
|
+
if @browserAbbrev == 'IE'
|
591
|
+
panel.link(:text, what).click!
|
592
|
+
elsif $USE_FIREWATIR
|
593
|
+
begin
|
594
|
+
panel.link(:text, what).click
|
595
|
+
rescue => e
|
596
|
+
unless rescue_me(e, __method__, rescue_me_command(:link, :id, what, :click), "#{panel.class}")
|
597
|
+
raise e
|
598
|
+
end
|
599
|
+
end
|
600
|
+
else
|
601
|
+
panel.link(:text, what).click(:wait => false)
|
602
|
+
end
|
603
|
+
sleep_for(1)
|
604
|
+
if validate(browser, @myName, __LINE__)
|
605
|
+
passed_to_log("Panel '#{what}' (by :text) closed.")
|
606
|
+
true
|
607
|
+
end
|
608
|
+
else
|
609
|
+
failed_to_log("Panel '#{strg}' (by :text) still open.")
|
610
|
+
end
|
611
|
+
rescue
|
612
|
+
failed_to_log("Click on '#{strg}'(by :text) failed: '#{$!}' (#{__LINE__})")
|
613
|
+
end
|
614
|
+
|
615
|
+
#def close_modal_ie(title, button = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false)
|
616
|
+
# #TODO needs simplifying and debug code cleaned up
|
617
|
+
# title = translate_popup_title(title)
|
618
|
+
# msg = "'#{title}'"
|
619
|
+
# msg << " with text '#{text}'" if text.length > 0
|
620
|
+
# msg << " (#{desc})" if desc.length > 0
|
621
|
+
# @ai.Opt("WinSearchChildren", 1) # Match any substring in the title
|
622
|
+
# if @ai.WinWait(title, text, wait) > 0
|
623
|
+
# myHandle = @ai.WinGetHandle(title, text)
|
624
|
+
# full_text = @ai.WinGetText(title)
|
625
|
+
# #debug_to_report("Found popup handle:'#{myHandle}', title:'#{title}', text:'#{full_text}'")
|
626
|
+
# if myHandle.length > 0
|
627
|
+
# debug_to_log("hwnd: #{myHandle.inspect}")
|
628
|
+
# passed_to_log("#{msg} appeared.") unless quiet
|
629
|
+
# sleep_for(0.5)
|
630
|
+
# @ai.WinActivate(title, text)
|
631
|
+
# if @ai.WinActive(title, text) # > 0 #Hack to prevent fail when windows session locked
|
632
|
+
# debug_to_log("#{msg} activated.")
|
633
|
+
# if @ai.ControlFocus(title, text, button) # > 0
|
634
|
+
# controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{button}]")
|
635
|
+
# if not controlHandle
|
636
|
+
# button = "&#{button}"
|
637
|
+
# controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{button}]")
|
638
|
+
# end
|
639
|
+
# debug_to_log("Handle for button '#{button}': [#{controlHandle}]")
|
640
|
+
# debug_to_log("#{msg} focus gained.")
|
641
|
+
# # sleep_for(2)
|
642
|
+
# if @ai.ControlClick(title, text, button, side) # > 0
|
643
|
+
# # if @ai.ControlClick(title, text, "[Handle:#{controlHandle}]", side) > 0
|
644
|
+
# # debug_to_log("#{msg} #{side} click on 'Handle:#{controlHandle}'." )
|
645
|
+
# debug_to_log("#{msg} #{side} click on '#{button}' successful.")
|
646
|
+
# sleep_for(1)
|
647
|
+
# if @ai.WinExists(title, text) > 0
|
648
|
+
# debug_to_log("#{msg} close popup failed on click '#{button}'. Trying WinClose. (#{__LINE__})")
|
649
|
+
# @ai.WinClose(title, text)
|
650
|
+
# if @ai.WinExists(title, text) > 0
|
651
|
+
# debug_to_log("#{msg} close popup failed with WinClose('#{title}','#{text}'). (#{__LINE__})")
|
652
|
+
# @ai.WinKill(title, text)
|
653
|
+
# if @ai.WinExists(title, text) > 0
|
654
|
+
# debug_to_log("#{msg} close popup failed with WinKill('#{title}','#{text}'). (#{__LINE__})")
|
655
|
+
# else
|
656
|
+
# debug_to_log("#{msg} closed successfully with WinKill('#{title}','#{text}').")
|
657
|
+
# end
|
658
|
+
# else
|
659
|
+
# debug_to_log("#{msg} closed successfully with WinClose('#{title}','#{text}').")
|
660
|
+
# end
|
661
|
+
# else
|
662
|
+
# passed_to_log("#{msg} closed successfully.") unless quiet
|
663
|
+
# end
|
664
|
+
# else
|
665
|
+
# failed_to_log("#{msg} #{side} click on '#{button}' failed. (#{__LINE__})")
|
666
|
+
# end
|
667
|
+
# else
|
668
|
+
# failed_to_log("#{msg} Unable to gain focus on button (#{__LINE__})")
|
669
|
+
# end
|
670
|
+
# else
|
671
|
+
# failed_to_log("#{msg} Unable to activate (#{__LINE__})")
|
672
|
+
# end
|
673
|
+
# else
|
674
|
+
# failed_to_log("#{msg} did not appear after #{wait} seconds. (#{__LINE__})")
|
675
|
+
# end
|
676
|
+
# else
|
677
|
+
# failed_to_log("#{msg} did not appear after #{wait} seconds. (#{__LINE__})")
|
678
|
+
# end
|
679
|
+
#rescue
|
680
|
+
# failed_to_log("Close popup title=#{title} failed: '#{$!}' (#{__LINE__})")
|
681
|
+
#end
|
682
|
+
|
683
|
+
# Close an browser window (popup) by clicking a link within it identified by the *:text* value of the link.
|
684
|
+
# @param [Watir::Browser] popup A reference to the browser window or container element to be closed.
|
685
|
+
# @param [String] what Uniquely identify the *:link* element within the popup by the value in its *:text* attribute.
|
686
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
687
|
+
def close_popup_by_text(popup, what = 'Close', desc = '')
|
688
|
+
count = 0
|
689
|
+
url = popup.url
|
690
|
+
if validate(popup, @myName, __LINE__)
|
691
|
+
count = string_count_in_string(popup.text, what)
|
692
|
+
if count > 0
|
693
|
+
begin
|
694
|
+
popup.link(:text, what).click
|
695
|
+
rescue => e
|
696
|
+
unless rescue_me(e, __method__, rescue_me_command(:link, :text, what, :click), "#{popup.class}")
|
697
|
+
raise e
|
698
|
+
end
|
699
|
+
end
|
700
|
+
passed_to_log("Popup #{url} closed by clicking link with text '#{what}'. #{desc}")
|
701
|
+
true
|
702
|
+
else
|
703
|
+
failed_to_log("Link :text=>'#{what}' for popup #{url} not found. #{desc}")
|
704
|
+
end
|
705
|
+
end
|
706
|
+
rescue
|
707
|
+
failed_to_log("Close popup #{url} with click link :text+>'#{what}' failed: '#{$!}' (#{__LINE__})")
|
708
|
+
debug_to_log("#{strg} appears #{count} times in popup.text.")
|
709
|
+
raise
|
710
|
+
end
|
711
|
+
|
712
|
+
# Close a modal dialog.
|
713
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
714
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
715
|
+
# @param [String] button The display name of the button to be clicked.
|
716
|
+
# @param [String] text The text of the window to be closed. Matched from beginning of string in Windows
|
717
|
+
# with Internet Explorer (regular expressions will fail). Use enough of beginning of the text string, in quotes,
|
718
|
+
# to assure the correct modal is found. This will give best portability.
|
719
|
+
# @param [String] side A string identifying which mouse button to click.
|
720
|
+
# @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
|
721
|
+
def close_modal(browser, title="", button="OK", text='', side = 'primary', wait = WAIT)
|
722
|
+
case @targetBrowser.abbrev
|
723
|
+
when 'IE'
|
724
|
+
close_modal_ie(browser, title, button, text, side, wait)
|
725
|
+
when 'FF'
|
726
|
+
close_modal_ff(browser, title, button, text, side)
|
727
|
+
when 'S'
|
728
|
+
close_modal_s
|
729
|
+
when 'C', 'GC'
|
730
|
+
close_modal_c(browser, title)
|
731
|
+
end
|
732
|
+
end
|
733
|
+
|
734
|
+
# TODO: Logging
|
735
|
+
# Close a Chrome modal popup by :url.
|
736
|
+
def close_modal_c(browser, url)
|
737
|
+
browser.window(:url, url).close
|
738
|
+
end
|
739
|
+
|
740
|
+
# TODO: Logging
|
741
|
+
# Close a Safari modal popup by closing the frontmost Safari dialog. Mac OSX only.
|
742
|
+
def close_modal_s
|
743
|
+
# simply closes the frontmost Safari dialog
|
744
|
+
Appscript.app("Safari").activate
|
745
|
+
Appscript.app("System Events").processes["Safari"].key_code(52)
|
746
|
+
end
|
747
|
+
|
748
|
+
# Close an IE modal popup by its title using AutoItX3. Windows only.
|
749
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
750
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
751
|
+
# @param [String] button The display name of the button to be clicked.
|
752
|
+
# @param [String] text The text of the window to be closed. Matched from beginning of string. Do not use regular expression
|
753
|
+
# @param [String] side A string identifying which mouse button to click.
|
754
|
+
# @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
|
755
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
756
|
+
# @param [Boolean] quiet If true, fewer messages and pass/fail validations are logged.
|
757
|
+
def close_modal_ie(browser, title="", button="OK", text='', side = 'primary', wait = WAIT, desc = '', quiet = false)
|
758
|
+
#TODO needs simplifying, incorporating text verification, and debug code cleaned up
|
759
|
+
title = translate_popup_title(title)
|
760
|
+
msg = "Modal window (popup) '#{title}'"
|
761
|
+
if @ai.WinWait(title, text, wait) > 0
|
762
|
+
myHandle = @ai.WinGetHandle(title, text)
|
763
|
+
if myHandle.length > 0
|
764
|
+
debug_to_log("hwnd: #{myHandle.inspect}")
|
765
|
+
passed_to_log("#{msg} appeared.") unless quiet
|
766
|
+
window_handle = "[HANDLE:#{myHandle}]"
|
767
|
+
sleep_for(0.5)
|
768
|
+
@ai.WinActivate(window_handle)
|
769
|
+
if @ai.WinActive(window_handle) > 0
|
770
|
+
debug_to_log("#{msg} activated.")
|
771
|
+
controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{button}]")
|
772
|
+
if not controlHandle.length > 0
|
773
|
+
button = "&#{button}"
|
774
|
+
controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{button}]")
|
775
|
+
end
|
776
|
+
debug_to_log("Handle for button '#{button}': [#{controlHandle}]")
|
777
|
+
debug_to_log("#{msg} focus gained.")
|
778
|
+
if @ai.ControlClick(title, '', "[CLASS:Button; TEXT:#{button}]") > 0
|
779
|
+
passed_to_log("#{msg} #{side} click on '[CLASS:Button; TEXT:#{button}]' successful.")
|
780
|
+
sleep_for(0.5)
|
781
|
+
if @ai.WinExists(window_handle) > 0
|
782
|
+
debug_to_log("#{msg} close popup failed on click '#{button}'. Trying WinClose. (#{__LINE__})")
|
783
|
+
@ai.WinClose(title, text)
|
784
|
+
if @ai.WinExists(window_handle) > 0
|
785
|
+
debug_to_log("#{msg} close popup failed with WinClose(#{window_handle}). (#{__LINE__})")
|
786
|
+
@ai.WinKill(window_handle)
|
787
|
+
if @ai.WinExists(window_handle) > 0
|
788
|
+
debug_to_log("#{msg} close popup failed with WinKill(#{window_handle}). (#{__LINE__})")
|
789
|
+
else
|
790
|
+
debug_to_log("#{msg} closed successfully with WinKill(#{window_handle}).")
|
791
|
+
end
|
792
|
+
else
|
793
|
+
debug_to_log("#{msg} closed successfully with WinClose(#{window_handle}).")
|
794
|
+
end
|
795
|
+
else
|
796
|
+
passed_to_log("#{msg} closed successfully.")
|
797
|
+
end
|
798
|
+
else
|
799
|
+
failed_to_log("#{msg} #{side} click on '[CLASS:Button; TEXT:#{button}]' failed. (#{window_handle}) (#{__LINE__})")
|
800
|
+
end
|
801
|
+
else
|
802
|
+
failed_to_log("#{msg} Unable to activate (#{window_handle}) (#{__LINE__})")
|
803
|
+
end
|
804
|
+
else
|
805
|
+
failed_to_log("#{msg} did not appear after #{wait} seconds. (#{window_handle}) (#{__LINE__})")
|
806
|
+
end
|
807
|
+
else
|
808
|
+
failed_to_log("#{msg} did not appear after #{wait} seconds.(#{window_handle}) (#{__LINE__})")
|
809
|
+
end
|
810
|
+
rescue
|
811
|
+
failed_to_log("Close popup title=#{title} failed: '#{$!}' (#{__LINE__})")
|
812
|
+
end
|
813
|
+
|
814
|
+
#alias close_popup_validate_text close_modal_ie
|
815
|
+
#alias close_popup close_modal_ie
|
816
|
+
|
817
|
+
# private :close_modal_ie
|
818
|
+
|
819
|
+
# Close an Internet Explorer modal popup by its title. Calls close_modal_ie. Windows only.
|
820
|
+
# @deprecated Use close_modal.
|
821
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
822
|
+
# @param [String] button The display name of the button to be clicked.
|
823
|
+
# @param [String] text The text of the window to be closed. Matched from beginning of string.
|
824
|
+
# @param [String] side A string identifying which mouse button to click.
|
825
|
+
# @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
|
826
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
827
|
+
# @param [Boolean] quiet If true, fewer messages and pass/fail validations are logged.
|
828
|
+
def close_popup(title = '', button = 'OK', text = '', side = 'primary',
|
829
|
+
wait = WAIT, desc = '', quiet = false)
|
830
|
+
debug_to_log("#{__method__} begin")
|
831
|
+
close_modal_ie(@myBrowser, title, button, text, side, wait, desc, quiet)
|
832
|
+
end
|
833
|
+
|
834
|
+
alias close_popup_validate_text close_popup
|
835
|
+
|
836
|
+
# Close a Firefox modal popup by its title.
|
837
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
838
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
839
|
+
# @param [String] button The display name of the button to be clicked.
|
840
|
+
# @param [String] text The text of the window to be closed. Matched from beginning of string.
|
841
|
+
# @param [String] side A string identifying which mouse button to click.
|
842
|
+
# @return [Boolean] True if the modal is successfully closed.
|
843
|
+
def close_modal_ff(browser, title="", button=nil, text='', side='')
|
844
|
+
title = translate_popup_title(title)
|
845
|
+
msg = "Modal dialog (popup): title=#{title} button='#{button}' text='#{text}' side='#{side}':"
|
846
|
+
modal = browser.modal_dialog(:timeout => WAIT)
|
847
|
+
if modal.exists?
|
848
|
+
modal_text = modal.text
|
849
|
+
if text.length > 0
|
850
|
+
if modal_text =~ /#{text}/
|
851
|
+
passed_to_log("#{msg} appeared with match on '#{text}'.")
|
852
|
+
else
|
853
|
+
failed_to_log("#{msg} appeared but did not match '#{text}' ('#{modal_text}).")
|
854
|
+
end
|
855
|
+
else
|
856
|
+
passed_to_log("#{msg} appeared.")
|
857
|
+
end
|
858
|
+
if button
|
859
|
+
modal.click_button(button)
|
860
|
+
else
|
861
|
+
modal.close
|
862
|
+
end
|
863
|
+
if modal.exists?
|
864
|
+
failed_to_log("#{msg} close failed. (#{__LINE__})")
|
865
|
+
else
|
866
|
+
passed_to_log("#{msg} closed successfully.")
|
867
|
+
true
|
868
|
+
end
|
869
|
+
else
|
870
|
+
failed_to_log("#{msg} did not appear after #{WAIT} seconds. (#{__LINE__})")
|
871
|
+
end
|
872
|
+
rescue
|
873
|
+
failed_to_log("#{msg} Unable to validate modal popup: '#{$!}'. (#{__LINE__})")
|
874
|
+
end
|
875
|
+
|
876
|
+
# Wait for a modal popup to appear and then close it.
|
877
|
+
# Used when modal popup in response to browser action is intermittent or unpredictable.
|
878
|
+
# @param [String] title The title of the window to be closed. Matched from beginning of string.
|
879
|
+
# @param [String] text The text of the window to be closed. Matched from beginning of string.
|
880
|
+
# @param [String] button The display name of the button to be clicked.
|
881
|
+
# @param [String] side A string identifying which mouse button to click.
|
882
|
+
# @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
|
883
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
884
|
+
# @return [Boolean] True if the modal is successfully closed.
|
885
|
+
def handle_popup(title, text = '', button= 'OK', side = 'primary', wait = WAIT, desc = '')
|
886
|
+
title = translate_popup_title(title)
|
887
|
+
msg = "'#{title}'"
|
888
|
+
if text.length > 0
|
889
|
+
msg << " with text '#{text}'"
|
890
|
+
end
|
891
|
+
@ai.Opt("WinSearchChildren", 1) # match title from start, forcing default
|
892
|
+
|
893
|
+
if button and button.length > 0
|
894
|
+
if button =~ /ok|yes/i
|
895
|
+
id = '1'
|
896
|
+
else
|
897
|
+
id = '2'
|
898
|
+
end
|
899
|
+
else
|
900
|
+
id = ''
|
901
|
+
end
|
902
|
+
|
903
|
+
if @ai.WinWait(title, '', wait) > 0
|
904
|
+
myHandle = @ai.WinGetHandle(title, '')
|
905
|
+
window_handle = "[HANDLE:#{myHandle}]"
|
906
|
+
full_text = @ai.WinGetText(window_handle)
|
907
|
+
debug_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text:'#{full_text}'")
|
908
|
+
|
909
|
+
controlHandle = @ai.ControlGetHandle(window_handle, '', "[CLASS:Button; TEXT:#{button}]")
|
910
|
+
if not controlHandle
|
911
|
+
# button = "&#{button}"
|
912
|
+
controlHandle = @ai.ControlGetHandle(window_handle, '', "[CLASS:Button; TEXT:&#{button}]")
|
913
|
+
end
|
914
|
+
|
915
|
+
if text.length > 0
|
916
|
+
if full_text =~ /#{text}/
|
917
|
+
passed_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text includes '#{text}'. #{desc}")
|
918
|
+
else
|
919
|
+
failed_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text does not include '#{text}'. Closing it. #{desc}")
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
923
|
+
@ai.WinActivate(window_handle, '')
|
924
|
+
@ai.ControlClick(window_handle, '', id, side)
|
925
|
+
if @ai.WinExists(title, '') > 0
|
926
|
+
debug_to_log("#{msg} @ai.ControlClick on '#{button}' (ID:#{id}) with handle '#{window_handle}' failed to close window. Trying title.")
|
927
|
+
@ai.ControlClick(title, '', id, side)
|
928
|
+
if @ai.WinExists(title, '') > 0
|
929
|
+
debug_to_report("#{msg} @ai.ControlClick on '#{button}' (ID:#{id}) with title '#{title}' failed to close window. Forcing closed.")
|
930
|
+
@ai.WinClose(title, '')
|
931
|
+
if @ai.WinExists(title, '') > 0
|
932
|
+
debug_to_report("#{msg} @ai.WinClose on title '#{title}' failed to close window. Killing window.")
|
933
|
+
@ai.WinKill(title, '')
|
934
|
+
if @ai.WinExists(title, '') > 0
|
935
|
+
failed_to_log("#{msg} @ai.WinKill on title '#{title}' failed to close window")
|
936
|
+
else
|
937
|
+
passed_to_log("Killed: popup handle:'#{myHandle}', title:'#{title}'. #{desc}")
|
938
|
+
true
|
939
|
+
end
|
940
|
+
else
|
941
|
+
passed_to_log("Forced closed: popup handle:'#{myHandle}', title:'#{title}'. #{desc}")
|
942
|
+
true
|
943
|
+
end
|
944
|
+
else
|
945
|
+
passed_to_log("Closed on '#{button}': popup handle:'#{myHandle}', title:'#{title}'. #{desc}")
|
946
|
+
true
|
947
|
+
end
|
948
|
+
else
|
949
|
+
passed_to_log("Closed on '#{button}': popup handle:'#{myHandle}', title:'#{title}'. #{desc}")
|
950
|
+
true
|
951
|
+
end
|
952
|
+
|
953
|
+
else
|
954
|
+
failed_to_log("#{msg} did not appear after #{wait} seconds. #{desc} (#{__LINE__})")
|
955
|
+
end
|
956
|
+
rescue
|
957
|
+
failed_to_log("Unable to handle popup #{msg}: '#{$!}' #{desc} (#{__LINE__})")
|
958
|
+
|
959
|
+
end
|
960
|
+
|
961
|
+
# Return a reference to an IE browser window based on one of its attributes.
|
962
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
963
|
+
# @param [Symbol] how The element attribute used to identify the window: :url, :title, or :hwnd.
|
964
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
965
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
966
|
+
# @return [Watir::IE] A reference to the popup.
|
967
|
+
def find_popup(browser, how, what, desc = '')
|
968
|
+
msg = "Find popup :#{how}=>'#{what}'. #{desc}"
|
969
|
+
popup = Watir::IE.find(how, what) # TODO: too browser specific
|
970
|
+
sleep_for(1)
|
971
|
+
debug_to_log("#{popup.inspect}")
|
972
|
+
if is_browser?(popup)
|
973
|
+
# title = popup.title
|
974
|
+
passed_to_log(msg)
|
975
|
+
return popup
|
976
|
+
else
|
977
|
+
failed_to_log(msg)
|
978
|
+
end
|
979
|
+
rescue
|
980
|
+
failed_to_log("Unable to find popup :#{how}=>'#{what}'. #{desc} '#{$!}' (#{__LINE__})")
|
981
|
+
end
|
982
|
+
|
983
|
+
# Confirm that the object passed in *browser* is actually a Browser object.
|
984
|
+
# @param [Watir::Browser] browser A reference to the window or container element to be tested.
|
985
|
+
def is_browser?(browser)
|
986
|
+
myClass = browser.class.to_s
|
987
|
+
case @targetBrowser.abbrev
|
988
|
+
when 'IE'
|
989
|
+
myClass =~ /Watir::IE|Watir::Browser/i
|
990
|
+
when 'FF'
|
991
|
+
myClass =~ /Watir::Browser/i
|
992
|
+
when 'S'
|
993
|
+
myClass =~ /Watir::Browser/i
|
994
|
+
when 'C'
|
995
|
+
myClass =~ /Watir::Browser/i
|
996
|
+
end
|
997
|
+
end
|
998
|
+
|
999
|
+
alias is_browser is_browser?
|
1000
|
+
|
1001
|
+
# Translate window title supplied in *title* to a title appropriate for the targeted browser and version
|
1002
|
+
# actually being run.
|
1003
|
+
# Used primarily for handling of modal popups and dialogs.
|
1004
|
+
# This allows cross-browser compatibility for handling modal popups and other windows accessed by titlt.
|
1005
|
+
# @param [String] title The title of the window to be closed.
|
1006
|
+
def translate_popup_title(title)
|
1007
|
+
new_title = title
|
1008
|
+
case @browserAbbrev
|
1009
|
+
when 'IE'
|
1010
|
+
if @browserVersion
|
1011
|
+
case @browserVersion
|
1012
|
+
when '8.0'
|
1013
|
+
case title
|
1014
|
+
when "Microsoft Internet Explorer"
|
1015
|
+
new_title = "Message from webpage"
|
1016
|
+
when "The page at"
|
1017
|
+
new_title = "Message from webpage"
|
1018
|
+
end
|
1019
|
+
when '7.0'
|
1020
|
+
case title
|
1021
|
+
when "Message from webpage"
|
1022
|
+
new_title = "Microsoft Internet Explorer"
|
1023
|
+
when "The page at"
|
1024
|
+
new_title = "Windows Internet Explorer"
|
1025
|
+
end
|
1026
|
+
when '6.0'
|
1027
|
+
case title
|
1028
|
+
when "Message from webpage"
|
1029
|
+
new_title = "Microsoft Internet Explorer"
|
1030
|
+
when "The page at"
|
1031
|
+
new_title = "Microsoft Internet Explorer"
|
1032
|
+
end
|
1033
|
+
else
|
1034
|
+
case title
|
1035
|
+
when "Microsoft Internet Explorer"
|
1036
|
+
new_title = "Message from webpage"
|
1037
|
+
when "The page at"
|
1038
|
+
new_title = "Message from webpage"
|
1039
|
+
end
|
1040
|
+
end
|
1041
|
+
else
|
1042
|
+
case title
|
1043
|
+
when "Microsoft Internet Explorer"
|
1044
|
+
new_title = "Message from webpage"
|
1045
|
+
when "The page at"
|
1046
|
+
new_title = "Message from webpage"
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
when 'FF'
|
1050
|
+
case title
|
1051
|
+
when 'File Download'
|
1052
|
+
new_title = 'Opening'
|
1053
|
+
when "Microsoft Internet Explorer"
|
1054
|
+
new_title = 'The page at'
|
1055
|
+
when "Message from webpage"
|
1056
|
+
new_title = 'The page at'
|
1057
|
+
end
|
1058
|
+
when 'C'
|
1059
|
+
case title
|
1060
|
+
when 'File Download'
|
1061
|
+
new_title = 'Save As'
|
1062
|
+
when "Microsoft Internet Explorer"
|
1063
|
+
new_title = 'The page at'
|
1064
|
+
when "Message from webpage"
|
1065
|
+
new_title = 'The page at'
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
new_title
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
# Identify the exact version of the Browser currently being executed.
|
1072
|
+
# @todo Bring up to date with newer browser versions
|
1073
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
1074
|
+
def get_browser_version(browser)
|
1075
|
+
debug_to_log("starting get_browser_version")
|
1076
|
+
case @targetBrowser.abbrev
|
1077
|
+
when 'IE'
|
1078
|
+
@browserAbbrev = 'IE'
|
1079
|
+
@browserName = 'Internet Explorer'
|
1080
|
+
if $watir_script
|
1081
|
+
@browserAppInfo = browser.document.invoke('parentWindow').navigator.appVersion
|
1082
|
+
else
|
1083
|
+
@browserAppInfo = browser.execute_script("return navigator.userAgent;")
|
1084
|
+
end
|
1085
|
+
@browserAppInfo =~ /MSIE\s(.*?);/
|
1086
|
+
@browserVersion = $1
|
1087
|
+
when 'FF'
|
1088
|
+
@browserAbbrev = 'FF'
|
1089
|
+
@browserName = 'Firefox'
|
1090
|
+
@browserVersion = '6.01' #TODO: get actual version from browser
|
1091
|
+
@browserAppInfo = browser.execute_script("return navigator.userAgent;")
|
1092
|
+
debug_to_log("#{@browserName}, @browserAppInfo: (#{@browserAppInfo})")
|
1093
|
+
when 'S'
|
1094
|
+
@browserAbbrev = 'S'
|
1095
|
+
@browserName = 'Safari'
|
1096
|
+
@browserVersion = '5.0.4' #TODO: get actual version from browser itself
|
1097
|
+
@browserAppInfo = browser.execute_script("return navigator.userAgent;")
|
1098
|
+
debug_to_log("#{@browserName}, @browserAppInfo: (#{@browserAppInfo})")
|
1099
|
+
when 'C'
|
1100
|
+
@browserAbbrev = 'C'
|
1101
|
+
@browserName = 'Chrome'
|
1102
|
+
@browserVersion = '11.0' #TODO: get actual version from browser
|
1103
|
+
@browserAppInfo = browser.execute_script("return navigator.userAgent;")
|
1104
|
+
debug_to_log("#{@browserName}, @browserAppInfo: (#{@browserAppInfo})")
|
1105
|
+
end
|
1106
|
+
rescue
|
1107
|
+
debug_to_log("Unable to determine #{@browserAbbrev} browser version: '#{$!}' (#{__LINE__})")
|
1108
|
+
ensure
|
1109
|
+
message_to_log("Browser: [#{@browserAbbrev} #{@browserVersion}]")
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
protected :get_browser_version
|
1113
|
+
|
1114
|
+
#def filter_bailout_from_rescue(err, msg)
|
1115
|
+
# if msg =~ /bailing out/i
|
1116
|
+
# raise err
|
1117
|
+
# else
|
1118
|
+
# error_to_log(msg)
|
1119
|
+
# end
|
1120
|
+
#end
|
1121
|
+
|
1122
|
+
# @!group Browser
|
1123
|
+
|
1124
|
+
# Open and attach a browser popup window where the link to open it and its title contain the same string.
|
1125
|
+
# @deprecated
|
1126
|
+
def open_popup_through_link_title(browser, title, pattern, name)
|
1127
|
+
click_title(browser, title)
|
1128
|
+
#TODO need some kind of wait for process here
|
1129
|
+
sleep_for 2
|
1130
|
+
attach_popup_by_url(browser, pattern, name)
|
1131
|
+
rescue
|
1132
|
+
failed_to_log("Unable to open popup '#{name}': '#{$!}' (#{__LINE__})")
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
# @!group Error Handling
|
1136
|
+
|
1137
|
+
# Verifies health of the browser. Looks for common http and system errors that are unrecoverable and
|
1138
|
+
# attempts to gracefully bail out of the script.
|
1139
|
+
# Calls rescue_me() when trying to capture the text to filter out known false errors
|
1140
|
+
# and handle container elements that don't respond to the .text method.
|
1141
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
1142
|
+
# @param [String] file_name The file name of the executing script.
|
1143
|
+
# @param [Fixnum] lnbr Contains a message or description intended to appear in the log and/or report output
|
1144
|
+
# @param [Boolean] dbg If set to true additional debug messages are written to the log.
|
1145
|
+
#
|
1146
|
+
# @return [Boolean] True if no error conditions have been encountered.
|
1147
|
+
def validate(browser, file_name = @myName, lnbr = "#{__LINE__}", dbg = false)
|
1148
|
+
debug_to_log("#{__method__} begin") if dbg
|
1149
|
+
msg = ''
|
1150
|
+
myOK = true
|
1151
|
+
if not browser
|
1152
|
+
msg = "#{file_name}----browser is nil object. (#{lnbr})"
|
1153
|
+
myOK = false
|
1154
|
+
elsif not browser.class.to_s =~ /Watir/
|
1155
|
+
msg = "#{file_name}----not a Watir object. (#{lnbr})"
|
1156
|
+
debug_to_log(browser.inspect)
|
1157
|
+
myOK = false
|
1158
|
+
|
1159
|
+
else
|
1160
|
+
if browser.respond_to?(:url)
|
1161
|
+
if not browser.url == @currentURL
|
1162
|
+
@currentURL = browser.url
|
1163
|
+
debug_to_log("Current URL: [#{@currentURL}]")
|
1164
|
+
# mark_testlevel( "Current URL: [#{@currentURL}]", 1 )
|
1165
|
+
end
|
1166
|
+
end
|
1167
|
+
|
1168
|
+
if @capture_js_errors
|
1169
|
+
if browser.respond_to?(:status)
|
1170
|
+
if browser.status.downcase =~ /errors? on page/ and
|
1171
|
+
not browser.status.downcase.include?('Waiting for')
|
1172
|
+
capture_js_error(browser)
|
1173
|
+
end
|
1174
|
+
end
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
begin
|
1178
|
+
browser_text = browser.text.downcase
|
1179
|
+
rescue => e
|
1180
|
+
unless rescue_me(e, __method__, "browser.text.downcase", "#{browser.class}", browser)
|
1181
|
+
debug_to_log("browser.text.downcase in #{__method__} #{browser.class}")
|
1182
|
+
debug_to_log("#{get_callers}")
|
1183
|
+
raise e
|
1184
|
+
else
|
1185
|
+
return true
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
if browser_text
|
1190
|
+
if browser_text.match(/unrecognized error condition has occurred/i)
|
1191
|
+
msg = "#{file_name}----Unrecognized Exception occurred. (#{lnbr})"
|
1192
|
+
myOK = false
|
1193
|
+
|
1194
|
+
elsif browser_text.match(/cannot find server or dns error/i)
|
1195
|
+
msg = "#{file_name}----Cannot find server error or DNS error. (#{lnbr})"
|
1196
|
+
myOK = false
|
1197
|
+
|
1198
|
+
elsif browser_text.match(/the rpc server is unavailable/i)
|
1199
|
+
msg = "#{file_name}----RPC server unavailable. (#{lnbr})"
|
1200
|
+
myOK = false
|
1201
|
+
|
1202
|
+
elsif browser_text.match(/404 not found/i) or
|
1203
|
+
browser_text.match(/the page you were looking for does\s*n[o']t exist/i)
|
1204
|
+
msg = "#{file_name}----RFC 2068 HTTP/1.1: 404 URI Not Found. (#{lnbr})"
|
1205
|
+
myOK = false
|
1206
|
+
|
1207
|
+
elsif browser_text.match(/we're sorry, but something went wrong/i) or
|
1208
|
+
browser_text.match(/http status 500/i)
|
1209
|
+
msg = "#{file_name}----RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
|
1210
|
+
myOK = false
|
1211
|
+
|
1212
|
+
elsif browser_text.match(/internet explorer cannot display the webpage/i)
|
1213
|
+
msg = "#{file_name}----Probably RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
|
1214
|
+
myOK = false
|
1215
|
+
|
1216
|
+
elsif browser_text.match(/503.*service unavailable/i)
|
1217
|
+
msg = "#{file_name}----RFC 2068 HTTP/1.1: 503 Service Unavailable. (#{lnbr})"
|
1218
|
+
myOK = false
|
1219
|
+
|
1220
|
+
elsif browser_text.match(/java.lang.NullPointerException/i)
|
1221
|
+
msg = "#{file_name}----java.lang.NullPointerException. (#{lnbr})"
|
1222
|
+
myOK = false
|
1223
|
+
|
1224
|
+
elsif browser_text.match(/due to unscheduled maintenance/i)
|
1225
|
+
msg = "#{file_name}----Due to unscheduled maintenance. (#{lnbr})"
|
1226
|
+
myOK = false
|
1227
|
+
|
1228
|
+
elsif browser_text.match(/network\s+error\s*(.+)$/i)
|
1229
|
+
$1.chomp!
|
1230
|
+
msg = "#{file_name}----Network Error #{$1}. (#{lnbr})"
|
1231
|
+
myOK = false
|
1232
|
+
|
1233
|
+
elsif browser_text.match(/warning: page has expired/i)
|
1234
|
+
msg = "#{file_name}----Page using information from form has expired. Not automatically resubmitted. (#{lnbr})"
|
1235
|
+
myOK = false
|
1236
|
+
|
1237
|
+
elsif browser_text.match(/no backend server available/i)
|
1238
|
+
msg = "#{file_name}----Cannot Reach Server (#{lnbr})"
|
1239
|
+
myOK = false
|
1240
|
+
|
1241
|
+
elsif browser_text.match(/sign on\s+.+\s+unsuccessful/i)
|
1242
|
+
msg = "#{file_name}----Invalid Id or Password (#{lnbr})"
|
1243
|
+
myOK = false
|
1244
|
+
|
1245
|
+
elsif browser_text.match(/you are not authorized/i)
|
1246
|
+
msg = "#{file_name}----Not authorized to view this page. (#{lnbr})"
|
1247
|
+
myOK = false
|
1248
|
+
|
1249
|
+
elsif browser_text.match(/too many incorrect login attempts have been made/i)
|
1250
|
+
msg = "#{file_name}----Invalid Id or Password. Too many tries. (#{lnbr})"
|
1251
|
+
myOK = false
|
1252
|
+
|
1253
|
+
elsif browser_text.match(/system error\.\s+an error has occurred/i)
|
1254
|
+
msg = "#{file_name}----System Error. An error has occurred. Please try again or call the Help Line for assistance. (#{lnbr})"
|
1255
|
+
myOK = false
|
1256
|
+
|
1257
|
+
elsif browser_text.match(/Internal Server failure,\s+NSAPI plugin/i)
|
1258
|
+
msg = "#{file_name}----Internal Server failure, NSAPI plugin. (#{lnbr})"
|
1259
|
+
myOK = false
|
1260
|
+
|
1261
|
+
elsif browser_text.match(/Error Page/i)
|
1262
|
+
msg = "#{file_name}----Error Page. (#{lnbr})"
|
1263
|
+
myOK = false
|
1264
|
+
|
1265
|
+
elsif browser_text.match(/The website cannot display the page/i)
|
1266
|
+
msg = "#{file_name}----HTTP 500. (#{lnbr})"
|
1267
|
+
myOK = false
|
1268
|
+
|
1269
|
+
# elsif browser_text.match(/Insufficient Data/i)
|
1270
|
+
# msg = "#{file_name}----Insufficient Data. (#{lnbr})"
|
1271
|
+
# myOK = false
|
1272
|
+
|
1273
|
+
elsif browser_text.match(/The timeout period elapsed/i)
|
1274
|
+
msg = "#{file_name}----Time out period elapsed or server not responding. (#{lnbr})"
|
1275
|
+
myOK = false
|
1276
|
+
|
1277
|
+
elsif browser_text.match(/Unexpected\s+errors*\s+occur+ed\.\s+(?:-+)\s+(.+)/i)
|
1278
|
+
msg = "#{file_name}----Unexpected errors occurred. #{$2.slice(0, 120)} (#{lnbr})"
|
1279
|
+
if not browser_text.match(/close the window and try again/i)
|
1280
|
+
myOK = false
|
1281
|
+
else
|
1282
|
+
debug_to_log("#{msg}")
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
elsif browser_text.match(/Server Error in (.+) Application\.\s+(?:-+)\s+(.+)/i)
|
1286
|
+
msg = "#{file_name}----Server Error in #{1} Application. #{$2.slice(0, 100)} (#{lnbr})"
|
1287
|
+
myOK = false
|
1288
|
+
|
1289
|
+
elsif browser_text.match(/Server Error in (.+) Application\./i)
|
1290
|
+
msg = "#{file_name}----Server Error in #{1} Application. '#{browser_text.slice(0, 250)}...' (#{lnbr})"
|
1291
|
+
myOK = false
|
1292
|
+
|
1293
|
+
elsif browser_text.match(/An error has occur+ed\. Please contact support/i)
|
1294
|
+
msg = "#{file_name}----An error has occurred. Please contact support (#{lnbr})"
|
1295
|
+
myOK = false
|
1296
|
+
|
1297
|
+
end
|
1298
|
+
else
|
1299
|
+
debug_to_log("browser.text returned nil")
|
1300
|
+
end
|
1301
|
+
end
|
1302
|
+
|
1303
|
+
if not myOK
|
1304
|
+
msg << " (#{browser.url})"
|
1305
|
+
puts msg
|
1306
|
+
debug_to_log(browser.inspect)
|
1307
|
+
debug_to_log(browser.text)
|
1308
|
+
fatal_to_log(msg, lnbr)
|
1309
|
+
raise(RuntimeError, msg, caller)
|
1310
|
+
else
|
1311
|
+
debug_to_log("#{__method__} returning OK") if dbg
|
1312
|
+
return myOK
|
1313
|
+
end
|
1314
|
+
|
1315
|
+
rescue
|
1316
|
+
errmsg = $!
|
1317
|
+
if errmsg and errmsg.match(msg)
|
1318
|
+
errmsg = ''
|
1319
|
+
end
|
1320
|
+
bail_out(browser, lnbr, "#{msg} #{errmsg}")
|
1321
|
+
end
|
1322
|
+
|
1323
|
+
alias validate_browser validate
|
1324
|
+
|
1325
|
+
# @!endgroup Error Handling
|
1326
|
+
|
1327
|
+
# @!group Backward compatible usages
|
1328
|
+
|
1329
|
+
# Returns a reference to a browser window using the window's *:url* attribute. Calls attach_browser().
|
1330
|
+
# @example
|
1331
|
+
# mainwindow = open_browser('www.google.com')
|
1332
|
+
# click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
|
1333
|
+
# popup = attach_browser_by_url(mainwindow, '[url of new window]')
|
1334
|
+
# @param [Watir::Browser] browser A reference to the current browser window.
|
1335
|
+
# @param [String, Regexp] what The value in the targeted attribute that uniquely identifies the new window
|
1336
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
1337
|
+
# @return [Watir::Browser]
|
1338
|
+
def attach_browser_by_url(browser, what, desc = '')
|
1339
|
+
attach_browser(browser, :url, what, desc)
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
alias attach_browser_with_url attach_browser_by_url
|
1343
|
+
|
1344
|
+
# Returns a reference to a new browser window identified by its *:title* attribute. Used to attach a new browser window to a variable
|
1345
|
+
# which can then be passed to methods that require a *browser* parameter. Calls attach_browser().
|
1346
|
+
# @param (see #attach_browser_by_url)
|
1347
|
+
def attach_popup_by_title(browser, what, desc = '')
|
1348
|
+
attach_popup(browser, :title, what, desc)
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
# Returns a reference to a new browser window identified by its *:url* attribute. Used to attach a new browser window to a variable
|
1352
|
+
# which can then be passed to methods that require a *browser* parameter. Calls attach_browser().
|
1353
|
+
# @param (see #attach_browser_by_url)
|
1354
|
+
def attach_popup_by_url(browser, what, desc = '')
|
1355
|
+
attach_popup(browser, :url, what, desc)
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
alias get_popup_with_url attach_popup_by_url
|
1359
|
+
alias attach_popup_with_url attach_popup_by_url
|
1360
|
+
alias attach_iepopup attach_popup_by_url
|
1361
|
+
|
1362
|
+
# Close a popup browser window (non-modal) by clicking on a link with :title *what*.
|
1363
|
+
# This method does not check to make sure the popup is actually closed.
|
1364
|
+
# @param [Watir::Browser] popup A reference to the current popup browser window.
|
1365
|
+
# @param [String, Regexp] what The value in the targeted attribute that uniquely identifies the new window
|
1366
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
1367
|
+
# @return [Boolean] True if the click is successful.
|
1368
|
+
def close_popup_by_button_title(popup, what, desc = '')
|
1369
|
+
click(popup, :link, :title, what, desc)
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
# @!endgroup Backward
|
1373
|
+
|
1374
|
+
|
1375
|
+
end
|
1376
|
+
end
|
1377
|
+
end
|
1378
|
+
|