-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore-investigator-happypath-nomenus.rb
1051 lines (782 loc) · 23 KB
/
core-investigator-happypath-nomenus.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
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
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
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
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
####################################################################################
#
# INV-HPSCR-NM.rb
# Test "happy path" conditions as an Investigator
# No menu testing due to UI changes - 1/21/14
#
# Scott Wedel
# 14 January 2014
#
# Tests from the 'INV Script' sheet in the QC Test Modules V1.0 spreadsheet
#
####################################################################################
require 'rubygems'
require 'watir-webdriver'
require './salog.rb'
require 'headless'
# remove log file if it already exists, then create new one
File.delete( "error_log.txt" ) if File.exist?( "error_log.txt" )
# vars
login = 'invsite123'
pw = '1qaz@WSX'
site = 'http://develop.trialintel.com'
test_count = 0
fail_count = 0
loop = 0
sep = '=========================================================='
#menus = ['Recent Activity', 'Queries', 'Safety Reporting', 'Trial Intel', 'Admin Links']
temp = 0
timedate = Time.new
day = timedate.strftime("%d")
month = timedate.strftime("%B")
year = timedate.strftime("%Y")
#today = day.to_s + ' ' + month.to_s + ' ' + year.to_s
today = timedate.inspect.to_s
# start up browser
headless = Headless.new
headless.start
# uncomment the line corresponding to the browser against which you want to test (no arg = firefox)
b = Watir::Browser.new
# b = Watir::Browser.new :chrome
# b = Watir::Browser.new :ie
bver = b.execute_script("return navigator.userAgent")
salog( sep, "LOG" )
salog( 'INVESTIGATOR ROLE: \'HAPPY PATH\' AUTOMATED TESTS', "LOG" )
datestr = 'DATE RUN: ' + today.to_s
tgtstr = 'TARGET: ' + site
salog( datestr, "LOG" )
salog( tgtstr, "LOG" )
bstr = 'BROWSER: ' + bver
salog( bstr, "LOG" )
salog( sep, "LOG" )
b.goto site
# TEST #1: Login as Investigator
tst = "1 - LOGIN"
salog( tst, "LOG" )
salog( sep, "LOG" )
tst = '1.1: Login as Investigator'
test_count +=1
b.text_field( :id, 'username' ).when_present.set login
b.text_field( :id, 'password' ).when_present.set pw
btn = b.button( :class, 'btn btn-default btn-block' ).click
# wait for dashboard to load
sleep 3
#b.link( :title => 'Show/Hide Navigation Menu' ).when_present.click
utst = b.text.include? 'Hi, Inv Site1,2,3'
if ( utst == true )
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
salog( sep, "LOG" )
# TEST #2: MENUS ETC
#tst = "2 - MENUS, ETC."
#salog( tst, "LOG" )
#alog( sep, "LOG" )
#while loop < menus.length
#case loop
#when 0
# TEST 2.1 - correct links exist
#tst = "2." + (loop+1).to_s + ": " + menus[loop] + ": links exist"
#salog( tst, "LOG" )
#test_count +=1
#b.link( :text => menus[loop] ).when_present.click
#sleep 3
#ns_tst = b.link( :text => 'New Subjects' ).exists?
#tf_tst = b.link( :text => 'Today\'s Forms' ).exists?
#if( ns_tst == true && tf_tst == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# click links and make sure accordion expands
#TEST 2.2 - make sure accordions expand (New Subjects)
#tst = "2." + (loop+2).to_s + ": " + menus[loop] + ": accordions expand (New Subjects)"
#salog( tst, "LOG" )
#test_count +=1
#b.link( :text => 'New Subjects' ).click
#conex = b.html.include? 'Consented'
#vwbex = b.link( :text => 'View' ).exists?
#if ( conex == true && vwbex == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# TEST 2.3 - make sure accordions expand (Today\'s Forms)
#test_count += 1
#tst = "2." + (loop+3).to_s + ": " + menus[loop] + ": accordions expand (Today\'s Forms)"
#salog( tst, "LOG" )
#b.link( :text => 'Today\'s Forms' ).click
#exist = b.link( :text => 'View' ).exists?
#if ( exist == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
#when 1
# TEST 2.4 - proper links exist
#test_count += 1
#tst = "2." + (loop+3).to_s + ": " + menus[loop] + ": proper links exist"
#salog( tst, "LOG" )
#b.link( :text => menus[loop] ).click
#sleep 10
#opq_tst = b.link( :text => 'Open Queries I have Posted' ).exists?
#clq_tst = b.link( :text => 'Closed Queries I have Posted' ).exists?
#otq_tst = b.link( :text => 'Other Queries I did NOT create' ).exists?
# DEBUG
#puts 'Open Q: ' + opq_tst.to_s
#puts 'Clos Q: ' + clq_tst.to_s
#puts 'Othr Q: ' + otq_tst.to_s
#if ( opq_tst = true && clq_tst == true && otq_tst == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# TEST 2.5 - open queries/accordion expands
#test_count +=1
#tst = "2." + (loop+4).to_s + ": " + menus[loop] + ": accordions expand"
#salog( tst, "LOG" )
#b.link( :text => 'Open Queries I have Posted' ).when_present.click
#opqctst = b.text.include?( 'You don\'t have any open queries that belong to you' )
#exist = b.link( :text => 'View' ).exists?
#if ( opqctst == true || exist == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# TEST 2.6 - closed queries/accordion expands
#test_count +=1
#tst = "2." + (loop+5).to_s + ": " + menus[loop] + ": closed queries/accordion expands"
#salog( tst, "LOG" )
#b.link( :text => 'Closed Queries I have Posted' ).when_present.click
#clqctst = b.text.include?( 'You don\'t have any closed queries that belong to you' )
#exist = b.link( :text => 'View' ).exists?
#if ( clqctst == true || exist == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# TEST 2.7 - other queries
#test_count +=1
#tst = "2." + (loop+6).to_s + ": " + menus[loop] + ": other queries"
#salog( tst, "LOG" )
#exist = b.link( :text => 'View' ).exists?
#if ( exist == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
#when 2 # Safety Reporting
# TEST 2.8 - Safety Reporting
#test_count +=1
#tst = "2." + (loop+6).to_s + ": " + menus[loop]
#salog( tst, "LOG" )
#b.link( :text => menus[loop] ).click
#sleep 3
#cv_tst = b.link( :text => 'ConMed Visit Forms' ).exists?
#ae_tst = b.link( :text => 'Adverse Event Visit Forms' ).exists?
#if ( cv_tst == true && ae_tst == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
#when 3 #Trial Intel
# TEST 2.9 - Trial Intel
#test_count +=1
#tst = "2." + (loop+6).to_s + ": " + menus[loop]
#salog( tst, "LOG" )
#b.link( :text => menus[loop] ).click
#sleep 3
#np_tst = b.div( :class => 'top_section reportBox' ).exists?
#bt_tst = b.button( :class => 'addReport' ).exists?
#puts np_tst
#puts bt_tst
#test_count += 1
#if ( np_tst == true && bt_tst == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
#when 4 #Admin Links
# TEST 2.10 - Admin Links
#test_count +=1
#tst = "2." + (loop+6).to_s + ": " + menus[loop]
#salog( tst, "LOG" )
#b.link( :text => menus[loop] ).click
#sleep 3
#al_tst = b.text.include? 'Admin Links:'
#if al_tst == true
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
#end
#loop +=1
#end
# TEST 3: LEFT HAND NAVIGATION MENU
salog( '3. LEFT HAND NAVIGATION MENU', "LOG" )
salog( sep, "LOG" )
# 3.1: click "Sites" link, should retract accordion
tst = '3.1: Sites link retracts accordion'
b.link( :text => 'Sites' ).when_present.click
sleep 3
# make sure none of the sites are still shown (accordion has retracted)
exone = b.text.include? '101-Demo 101'
extwo = b.text.include? '102-Demo 102'
exthr = b.text.include? '103-Demo 103'
test_count +=1
if (exone == false && extwo == false && exthr == false)
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
#salog( sep, "LOG" )
# 3.2: click "Sites" link again, should expand accordion
tst = '3.2: Sites link expands accordion'
b.link( :text => 'Sites' ).when_present.click
sleep 3
# make sure the sites are shown (accordion has expanded)
exone = b.text.include? '101-Demo 101'
extwo = b.text.include? '102-Demo 102'
exthr = b.text.include? '103-Demo 103'
test_count +=1
if (exone == true && extwo == true && exthr == true)
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
salog( sep, "LOG" )
# TEST 4: view forms
salog( '4. VIEW FORMS', "LOG" )
salog( sep, "LOG" )
# 4.1: open a subject from the left menu, load form and verify
tst = '4.1: Open subject from left side menu, load form, and verify'
b.link( :text => '101-Demo 101' ).when_present.click
b.link( :text => '101-999' ).when_present.click
b.element( :css => '#ui-accordion-accordion-header-0 > a:nth-child(2)' ).when_present.click
b.element( :text => 'View' ).when_present.click
sleep 3 # wait for form to load
# verify subject ID & form name
# DEBUG: getting bg color from queried question
# puts b.div( :id => 'RFICSTAT' ).style 'background-color'
idex = b.text.include?( '101-999' )
frmex = b.text.include?( 'Informed Consent' )
test_count +=1
if (idex == true && frmex == true)
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
#salog( sep, "LOG" )
# go back to subject page
b.link( :text => 'Return to Subject' ).click
# 4.2: view sign-off/Investigator signature form REMOVED 12/09/2013
tst = '4.2: View sign-off/Investigator signature form (REMOVED 12/09/13)'
salog( tst, "LOG" )
salog( sep, "LOG" )
# b.element( :xpath => '/html/body/div[2]/div[2]/div[3]/div/div/div/div[2]/div/div/table[2]/tbody/tr[2]/td[5]/a' ).when_present.click
# sleep 2
# verify subject id and form title are present
#idex = b.text.include?( '101-999' )
#titex = b.text.include?( 'Investigator Signature' )
#test_count +=1
#if (idex == true && titex == true )
# salog( tst, "PASS" )
#else
# salog( tst, "FAIL" )
# fail_count +=1
#end
#salog( sep, "LOG" )
# go back to subject page
#b.link( :text => 'Return to Subject' ).click
# TEST 5: Create Queries in Query Manager
salog( '5. OPEN QUERY MANAGER', "LOG" )
salog( sep, "LOG" )
# 5.1: click on a question/response in form to open query manager
tst = '5.1: click on ?/response to open query manager'
#b.link( :text => '108-Demo 108' ).when_present.click
b.link( :text => '101-999' ).when_present.click
b.link( :text => 'View' ).when_present.click
b.goto( site + "/INFCONSForms/view/1?siteID=1" )
b.element(:css, "div.to_click").click
test_count +=1
qmex = b.link( :id, "ui-id-2" ).exists?
if ( qmex == true )
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
salog( sep, "LOG" )
# 5.2: verify "Query" exists in the dropdown
#tst = '5.2: verify \'Query\' exists in the dropdown'
#elems = Array.new
#elems = b.select_list( :id, "data[Query][query_type_id]" ).options
#0.upto(elems.length - 1) do |i|
#puts elems[i].text
#if (elems[i].text == 'Query' )
#temp +=1
#break
#end
#end
#test_count +=1
#if ( temp > 0 )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# 5.3: select Query, add note w. numbers/letters/symbols, submit query
#tst = '5.3: Select Query * Add Note w. numbers/letters/symbols * Submit Query'
#b.select_list( :id, "data[Query][query_type_id]" ).select 'Query'
#sleep 2
#b.text_field(:id, "data[QueryPost][0][post]").set "Th1s I$ 4 Qu3r& *()!"
#sleep 2
# click submit
#b.element(:id, "btnsubmit").click
#sleep 3
# now go to open queries tab and make sure the new query is there
#b.link( :id, "ui-id-2" ).click
#sleep 2
#b.link( :class, "btn btn-info AddPost").click
#sleep 2
#txtex = ( ( b.text.include? 'Th1s I$ 4 Qu3r& *()!' ) || ( b.text.include? 'Query' ))
#test_count +=1
#if txtex == true
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 5.4: Dismiss Query Manager
#tst = '5.4: Dismiss Query Manager'
#sleep 2
#b.element( :text => 'Return to Queries' ).when_present.click
#sleep 2
#b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
#sleep 2
#ex = b.text.include?( 'Query Manager' )
#test_count +=1
#puts ex
#if (ex == false)
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 5.5: verify background color of queried question/response
#tst = '5.5: verify background color of queried question/response'
#test_count +=1
#if (b.div( :id => 'RFICDTC' ).style 'background-color' == 'rgba(255, 249, 215)')
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#salog( sep, "LOG" )
# TEST 6: view & delete queries in query manager, QM column sorting
salog( '6. VIEW QUERIES IN QUERY MANAGER, QM COLUMN SORTING', "LOG" )
salog( sep, "LOG" )
# 6.1: Open QM & verify it opens to New Query tab
tst = '6.1: Open QM & verify it opens to New Query tab'
b.goto( site + "/INFCONSForms/view/1?siteID=1" )
b.element(:css, "div.to_click").click
test_count +=1
ex = b.text.include?( 'You don\'t have permissions to submit new queries.' )
if (ex == true)
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
# 6.2: switch to open queries tab, verify columns exist
b.link( :id, "ui-id-2" ).click
sleep 2
tst = '6.2: Verify correct columns exist'
mnunms = Array.new
mnunms = ['Query ID', 'Posted', 'Responses', 'Visit Name', 'Form Element', 'Posted By']
#puts b.table( :id => 'openQuery' )[1][2].text
tmp = 0
test_count +=1
rwct = b.table( :id => 'openQuery' ).rows.length
0.upto( rwct ) do |num|
ex = b.link( :text => mnunms[num] ).exists?
if ex == false
tmp +=1
break
end
end
if tmp == 0
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
# 6.3: verify sorting by column
# ascending
ascloop = 0
while ascloop < mnunms.length
tst = '6.2.' + ascloop.to_s + 'asc: Verify sorting ' + mnunms[ascloop] + ' column (ascending)'
b.link( :text => mnunms[ascloop] ).click
sleep 2
test_count +=1
topcell = b.table( :id => 'openQuery' )[1][ascloop].text.to_s
#puts topcell
nxtcell = b.table( :id => 'openQuery' )[2][ascloop].text.to_s
#puts nxtcell
if ( topcell <= nxtcell )
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
#break
end
ascloop +=1
end
dscloop = 0
while dscloop < mnunms.length
tst = '6.2.' + dscloop.to_s + 'desc: Verify sorting ' + mnunms[dscloop] + ' column (descending)'
b.link( :text => mnunms[dscloop] ).click
sleep 2
test_count +=1
topcell = b.table( :id => 'openQuery' )[1][dscloop].text.to_s
#puts topcell
nxtcell = b.table( :id => 'openQuery' )[2][dscloop].text.to_s
#puts nxtcell
if ( topcell >= nxtcell )
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
#break
end
dscloop +=1
end
# 6.4: delete query
#tst = '6.4: Delete query'
#qnum = b.table( :id => 'openQuery' )[1][0].text
#puts qnum
#b.element( :text => 'Delete' ).when_present.click
#sleep 2
#b.driver.switch_to.alert.accept
#sleep 2
#b.driver.switch_to.alert.accept
#test_count +=1
#psscnt = 0
#0.upto( rwct ) do |num|
#cpnum = b.table( :id => 'openQuery' )[1][num]
#if ( qnum == cpnum )
#salog( tst, "FAIL" )
#fail_count +=1
#break
#else
#psscnt +=1
#end
#end
#if ( psscnt > 0 )
#salog( tst, "PASS" )
#end
# 6.5: Dismiss Query Manager
tst = '6.5: Dismiss Query Manager'
#sleep 2
#b.element( :text => 'Return to Queries' ).when_present.click
sleep 2
b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
sleep 2
ex = b.text.include?( 'Query Manager' )
test_count +=1
#puts ex
if (ex == false)
salog( tst, "PASS" )
else
salog( tst, "FAIL" )
fail_count +=1
end
# puts 'Here is where you should return to subject'
#salog( sep, "LOG" )
# TEST 7: create protocol deviation query in Query Manager
#salog( '7. CREATE PROTOCOL DEVIATION QUERY IN QUERY MANAGER', "LOG" )
#salog( sep, "LOG" )
# 7.1: click on a question/response in form to open query manager
#tst = '7.1: click on ?/response to open query manager'
#b.link( :text => '108-Demo 108' ).when_present.click
#b.link( :text => 'Return to Subject' ).when_present.click
#sleep 3
#b.link( :text => '101-999' ).when_present.click
#b.link( :text => 'View' ).when_present.click
#b.link( :xpath => '/html/body/div[2]/div[2]/div[3]/div/div/div/div[2]/div/div/table[2]/tbody/tr[2]/td[5]/a' ).when_present.click
#b.goto( site + "/INFCONSForms/view/1701?siteID=1" )
#b.element(:css, "div.to_click").click
#test_count +=1
#qmex = b.link( :id, "ui-id-2" ).exists?
#if ( qmex == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 7.2: verify "Protocol Deviation" exists in the dropdown
#tst = '7.2: verify \'Protocol Deviation\' exists in the dropdown'
#mnuelems = Array.new
#mnuelems = b.select_list( :id, "data[Query][query_type_id]" ).options
#0.upto(mnuelems.length - 1) do |i|
#puts mnuelems[i].text
#if (mnuelems[i].text == 'Protocol Deviation' )
#temp +=1
#break
#end
#end
#test_count +=1
#if ( temp > 0 )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 7.3: create protocol deviation query
#tst = '7.3: create Protocol Deviation query'
#b.select_list( :id, "data[Query][query_type_id]" ).select 'Protocol deviation'
#sleep 2
#b.text_field(:id, "data[QueryPost][0][post]").set "Th1s I$ 4 PD Qu3r& *()!"
#sleep 2
# click submit
#b.element(:id, "btnsubmit").click
#sleep 3
# now go to protocol deviation tab and make sure the new query is there
#b.link( :id, "ui-id-3" ).click
#sleep 2
#b.link( :class, "btn btn-info AddPost").click
#sleep 2
#txtex = b.text.include? 'PD'
#test_count +=1
#if txtex == true
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 7.4: Dismiss Query Manager
#tst = '7.4: Dismiss Query Manager'
#sleep 2
#b.button( :id => 'btnReturnToQueries' ).click
#sleep 2
#b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
#sleep 2
#ex = b.text.include?( 'Query Manager' )
#test_count +=1
#puts ex
#if (ex == false)
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 7.5: Return to Query Manager, delete protocol deviation query
#tst = '7.5: Return to Query Manager, delete protocol deviation query'
#b.goto( site + "/INFCONSForms/view/1?siteID=1" )
#b.element(:css, "div.to_click").click
#b.link( :id, "ui-id-3" ).click
#sleep 2
#qnum = b.table( :id => 'PDopenQuery' )[1][0].text
#b.element( :text => 'Delete' ).when_present.click
#sleep 2
#b.driver.switch_to.alert.accept
#sleep 2
#b.driver.switch_to.alert.accept
#sleep 2
#rwct = b.table( :id => 'PDopenQuery' ).rows.length
#test_count +=1
#psscnt = 0
#0.upto( rwct ) do |num|
#cpnum = b.table( :id => 'PDopenQuery' )[1][num]
#if ( qnum == cpnum )
#salog( tst, "FAIL" )
#fail_count +=1
#break
#else
#psscnt +=1
#end
#end
#if ( psscnt > 0 )
#salog( tst, "PASS" )
#end
# dismiss query manager (no test case needed at this point)
#sleep 2
#b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
#sleep 5
# puts 'return to subject here'
b.link( :text => 'Return to Subject' ).when_present.click
salog( sep, "LOG" )
#salog( '8. CREATE GENERAL COMMENT QUERY IN QUERY MANAGER', "LOG" )
#salog( sep, "LOG" )
# TEST 8: create general comment query in Query Manager
#tst = '8.1: click ?/response to open Query Manager'
#sleep 3
#b.element( :xpath => '/html/body/div[2]/div[2]/div[3]/div/div/div/div[2]/div/div/table[2]/tbody/tr[2]/td[5]/a' ).when_present.click
#b.link( :text => 'View' ).when_present.click
#b.goto( site + "/INFCONSForms/view/1?siteID=1" )
#b.element(:css, "div.to_click").click
#test_count +=1
#cmex = b.link( :id, "ui-id-4" ).exists?
#if ( cmex == true )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# verify General Comment exists in dropdown
#tst = '8.2: verify \'General comment\' exists in the dropdown'
#gcmelems = Array.new
#gcmelems = b.select_list( :id, "data[Query][query_type_id]" ).options
#0.upto(gcmelems.length - 1) do |i|
#puts mnuelems[i].text
#if (gcmelems[i].text == 'General comment' )
#temp +=1
#break
#end
#end
#test_count +=1
#if ( temp > 0 )
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
# 8.3: create general comment query
#tst = '8.3: create General comment query'
# select General Comment from dropdown, submit query
#b.select_list( :id, "data[Query][query_type_id]" ).select 'General comment'
#sleep 2
#b.text_field(:id, "data[QueryPost][0][post]").set "Th1s I$ 4 GC Qu3r& *()!"
#sleep 2
# click submit
#b.element(:id, "btnsubmit").click
#sleep 3
# now go to general comment tab and make sure the new query is there
#b.link( :id, "ui-id-4" ).click
#sleep 2
#b.link( :class, "btn btn-info AddPost").click
#sleep 2
#txtex = b.text.include? 'GC'
#test_count +=1
#if txtex == true
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end
#sleep 2
#b.button( :id => 'btnReturnToQueries' ).click
#sleep 2
#b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
#sleep 2
# 8.4: delete general comment query in Query Manager
#tst = '8.4: Delete general comment query'
#b.goto( site + "/INFCONSForms/view/1?siteID=1" )
#b.element(:css, "div.to_click").click
#b.link( :id, "ui-id-4" ).click
#sleep 2
#qnum = b.table( :id => 'GCopenQuery' )[1][0].text
#b.element( :text => 'Delete' ).when_present.click
#sleep 2
#b.driver.switch_to.alert.accept
#sleep 2
#b.driver.switch_to.alert.accept
#sleep 5
#rwct = b.table( :id => 'GCopenQuery' ).rows.length
#test_count +=1
#psscnt = 0
#0.upto( rwct ) do |num|
#cpnum = b.table( :id => 'GCopenQuery' )[1][num]
#if ( qnum == cpnum )
#salog( tst, "FAIL" )
#fail_count +=1
#break
#else
#psscnt +=1
#end
#end
#if ( psscnt > 0 )
#salog( tst, "PASS" )
#end
# dismiss query manager
#sleep 2
#b.element( :xpath => '//body[@id=\'form_page_layout\']/div[3]/div/button' ).when_present.click
#sleep 5
# puts 'return to subject here'
#b.link( :text => 'Return to Subject' ).when_present.click
#salog( sep, "LOG" )
#salog( '9. APPLY/REMOVE SUBJECT DATA ENTRY LOCK', "LOG" )
#salog( sep, "LOG" )
# 9.1: Apply Subject Data Entry Lock
#tst = '9.1: Apply Subject Data Entry Lock'
#b.link( :text => 'Apply Data Entry Lock' ).when_present.click
#sleep 2
#b.driver.switch_to.alert.accept
# verify data cannot be entered/edited
#b.link( :text => 'Edit Subject' ).when_present.click
#sleep 3
#test_count +=1
#if b.text.include? 'The subject has been locked for data entry and editing is not possible.'
#salog( tst, "PASS" )
#else
#salog( tst, "FAIL" )
#fail_count +=1
#end