-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathselenium-webdriver.html
1368 lines (1316 loc) · 48.2 KB
/
selenium-webdriver.html
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
<script type="text/x-red" data-template-name="open-web">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> <span>Server</span></label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-browser"><i class="fa fa-empire"></i> <span>Browser</span></label>
<select id="node-input-browser" style="width:125px !important">
<option value="chrome">Chrome</option>
<option value="firefox">Firefox</option>
<option value="safari">Safari</option>
<option value="opera">Opera</option>
<option value="ie">IE</option>
</select>
</div>
<div class="form-row">
<label for="node-input-weburl"><i class="fa fa-empire"></i> <span>Web URL</span></label>
<input type="text" id="node-input-weburl">
</div>
<div class="form-row">
<label for="node-input-width"><i class="fa fa-empire"></i> <span>Width</span></label>
<input type="text" id="node-input-width" value="1024">
</div>
<div class="form-row">
<label for="node-input-height"><i class="fa fa-empire"></i> <span>Height</span></label>
<input type="text" id="node-input-height" value="768">
</div>
<div class="form-row">
<label for="node-input-webtitle"><i class="fa fa-empire"></i> <span>Web Title</span></label>
<input type="text" id="node-input-webtitle">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-maximized" checked style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-maximized" style="width: auto;">Maximize window</label>
</div>
</script>
<script type="text/x-red" data-help-name="open-web">
<p>Create an instance of selenium webdriver and connect to the Selenium Server when an event is triggered.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Browser</a>: specify the selenium node which support the web browser you wan tot test such as [Chrome, Firefox etc.,]</li>
<li><a>Server</a>: specify the selenium server configuration. It could be localhost or remote Selenium Server.</li>
<li><a>Web URL</a>: specify the web page to start browsing the targeted application for your test.</li>
<li><a>Web Title</a>: specify the expected title to compare if set. Otherwise this node will bypass the sanity check operation.</li>
<li><a>Timeout</a>: specify the timeout during lookup for the title operation.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the title is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.driver</code> Always pass webdriver object to the next node for ad-hoc function code.</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
<p><code>msg.payload</code> contains the title of the opened web page. This payload value will be used to compare with the expected Web Title value if that value is set.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('open-web', {
category : 'selenium',
defaults : {
name : {
value : ""
},
browser : {
value : "chrome",
required : true
},
weburl : {
value : "https://www.google.com/",
required : true
},
width : {
value : 1024,
validate : RED.validators.number()
},
height : {
value : 768,
validate : RED.validators.number()
},
webtitle : {
value : "Google"
},
timeout : {
value : 3000,
required : true,
validate : RED.validators.number()
},
maximized : {
value : true,
required : true
},
server : {
type : "selenium-server",
required : true
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "white-globe.png",
label : function() {
return this.name || this.topic || "Open URL";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="close-web">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
</script>
<script type="text/x-red" data-help-name="close-web">
<p>Close the web browser which is openned by the open-web node and finalize the selenium session.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('close-web', {
category : 'selenium',
defaults : {
name : {
value : ""
},
waitfor : {
value : 500,
validate : RED.validators.number()
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "white-globe.png",
label : function() {
return this.name || "Close";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="find-object">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
</script>
<script type="text/x-red" data-help-name="find-object">
<p>Find an object or element by using selenium webdriver <code>findElement()</code>.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('find-object', {
category : 'selenium',
defaults : {
name : {
value : ""
},
selector : {
value : "",
required : true
},
target : {
value : "",
required : true
},
timeout : {
value : 1000,
required : true,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Find Element";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="send-keys">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-text"><i class="fa fa-empire"></i> <span>Value</span></label>
<input type="text" id="node-input-text">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-clearval" value="false" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-clearval" style="width: 70%"> <span>Clear the element value before sending the keys.</span></label>
</div>
</script>
<script type="text/x-red" data-help-name="send-keys">
<p>Send keyboard keys to the <code>msg.element</code> from previous node or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Value</a>: specify the value to get. The <code>msg.value</code> will override the <code>Value</code> field if set.</li>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('send-keys', {
category : 'selenium',
defaults : {
name : {
value : ""
},
text : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
},
clearval : {
value : false
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Send Keys";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="click-on">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-clickon" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-clickon" style="width: 70%"> <span>Require manual approval on click to continue</span></label>
</div>
</script>
<script type="text/x-red" data-help-name="click-on">
<p>Click on the <code>msg.element</code> which is passed by previous node or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('click-on', {
category : 'selenium',
defaults : {
name : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
},
clickon : {
value : false
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Click On";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
},
button: {
onclick: function() {
var node = this;
$.ajax({
url: "onclick/" + this.id,
type:"POST",
success: function(resp) {
RED.notify(node._("inject.success",{ label:label }),"success");
},
error: function(jqXHR,textStatus,errorThrown) {
if (jqXHR.status == 404) {
RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.not-deployed")}),"error");
} else if (jqXHR.status == 500) {
RED.notify(node._("common.notification.error",{message:node._("inject.errors.failed")}),"error");
} else if (jqXHR.status == 0) {
RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.no-response")}),"error");
} else {
RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.unexpected",{status:jqXHR.status,message:textStatus})}),"error");
}
}
});
}
}
});
</script>
<script type="text/x-red" data-template-name="set-value">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-text"><i class="fa fa-empire"></i> <span>Value</span></label>
<input type="text" id="node-input-text">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
</script>
<script type="text/x-red" data-help-name="set-value">
<p>Set a value to the <code>value</code> attribute of the <code>msg.element</code> or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Value</a>: specify the value to get. The <code>msg.value</code> will override the <code>Value</code> field if set.</li>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('set-value', {
category : 'selenium',
defaults : {
name : {
value : ""
},
text : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Set Value";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="to-file">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-filename"><i class="fa fa-empire"></i> <span>File</span></label>
<input type="text" id="node-input-filename">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
</script>
<script type="text/x-red" data-help-name="to-file">
<p>Save a value to the <code>File</code> location with <code>msg.payload</code> content as a string.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>File</a>: specify the file path to write to. The <code>msg.filename</code> will override the <code>File</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the file writing operation is failed or unexpected operation occurred.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('to-file', {
category : 'selenium',
defaults : {
name : {
value : ""
},
filename : {
value : "./filename"
},
waitfor : {
value : 500,
validate : RED.validators.number()
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "To File";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="get-value">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-expected"><i class="fa fa-globe"></i> <span>Expected</span></label>
<input type="text" id="node-input-expected">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-savetofile" value="false" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-savetofile" style="width: 70%"> <span>Save the value to a specific filename.</span></label>
</div>
</script>
<script type="text/x-red" data-help-name="get-value">
<p>Get the value from <code>value</code> attribute of the <code>msg.element</code> or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Expected</a>: specify the expected value to compare. The <code>msg.expected</code> will override the <code>Expected</code> field if set.</li>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<p>If the <code>msg.filename</code> is passed through, the <code>msg.payload</code> will be written into the file path.</p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
<p><code>msg.payload</code> contains the result of the <code>value</code> attribute.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('get-value', {
category : 'selenium',
defaults : {
name : {
value : ""
},
expected : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
},
savetofile : {
value : false
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Get Value";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="get-attribute">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-attribute"><i class="fa fa-empire"></i> <span>Attribute</span></label>
<input type="text" id="node-input-attribute">
</div>
<div class="form-row">
<label for="node-input-expected"><i class="fa fa-empire"></i> <span>Expected</span></label>
<input type="text" id="node-input-expected">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-savetofile" value="false" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-savetofile" style="width: 70%"> <span>Save the value to a specific filename.</span></label>
</div>
</script>
<script type="text/x-red" data-help-name="get-attribute">
<p>Get the attribute from <code>attribute</code> of the <code>msg.element</code> or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Attribute</a>: specify the attribute to get. The <code>msg.attribute</code> will override the <code>Attribute</code> field if set.</li>
<li><a>Expected</a>: specify the expected value to cpmpare. The <code>msg.expected</code> field if set.</li>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<p>If the <code>msg.filename</code> is passed through, the <code>msg.payload</code> will be written into the file path.</p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
<p><code>msg.payload</code> contains the result of the <code>value</code> attribute.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('get-attribute', {
category : 'selenium',
defaults : {
name : {
value : ""
},
attribute : {
value : ""
},
expected : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
},
savetofile : {
value : false
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Get Attribute";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="get-text">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-expected"><i class="fa fa-globe"></i> <span>Expected</span></label>
<input type="text" id="node-input-expected">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-savetofile" value="false" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-savetofile" style="width: 70%"> <span>Save the value to a specific filename.</span></label>
</div>
</script>
<script type="text/x-red" data-help-name="get-text">
<p>Get the text of the <code>msg.element</code> passed from previous node or after waiting for the expected element is located.</p>
<strong>Inputs:</strong>
<p><ul>
<li><a>Expected</a>: specify the expected value to cpmpare. The <code>msg.expected</code> will override the <code>Expected</code> field if set.</li>
<li><a>By</a>: specify the way to find an element by selector. The <code>msg.selector</code> will override the <code>By</code> field if set.</li>
<li><a>Target</a>: specify the selector's value to lookup. The<code>msg.target</code> will override the <code>Target</code> field if set.</li>
<li><a>Timeout</a>: specify the timeout during lookup operation. The <code>msg.timeout</code> will override the <code>Timeout</code> field if set.</li>
<li><a>Wait For</a>: specify the time to wait before looing up. The <code>msg.waitfor</code> will override the <code>Wait For</code> field if set.</li>
</ul></p>
<p>If the <code>msg.filename</code> is passed through, the <code>msg.payload</code> will be written into the file path.</p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
<p><code>msg.payload</code> contains the result of the <code>text</code> attribute.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('get-text', {
category : 'selenium',
defaults : {
name : {
value : ""
},
expected : {
value : ""
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
},
savetofile : {
value : false
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Get Text";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="run-script">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-globe"></i> <span>Name</span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-selector"><i class="fa fa-empire"></i> <span>By</span></label>
<select id="node-input-selector" style="width:125px !important">
<option value="id">id</option>
<option value="name">name</option>
<option value="link">link</option>
<option value="xpath">xpath</option>
<option value="tagName">tagName</option>
<option value="className">className</option>
<option value="linkText">linkText</option>
<option value="cssSelector">cssSelector</option>
</select>
</div>
<div class="form-row">
<label for="node-input-target"><i class="fa fa-empire"></i> <span>Target</span></label>
<input type="text" id="node-input-target">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-empire"></i> <span>Timeout</span></label>
<input type="text" id="node-input-timeout" value="1000">
</div>
<div class="form-row">
<label for="node-input-waitfor"><i class="fa fa-empire"></i> <span>Wait For</span></label>
<input type="text" id="node-input-waitfor" value="00">
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-func"><i class="fa fa-wrench"></i> <span>Function</span></label>
<input type="hidden" id="node-input-func" autofocus="autofocus">
<input type="hidden" id="node-input-noerr">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px;" class="node-text-editor" id="node-input-func-editor" ></div>
</div>
</script>
<script type="text/x-red" data-help-name="run-script">
<p>A function block where you can write code to run in the browser context of an existing element.</p>
<p>The parameters is passed in as a JavaScript object called <code>msg.driver</code> and <code>msg.element</code>.</p>
<strong>Outputs:</strong>
<p><code>msg.error</code> When the object is unexpected or cannot find element, this node generates the error with detail information</p>
<p><code>msg.element</code> If the element is found, it will be passed though the msg object to the next node.</p>
<strong>Logging and Error Handling</strong>
<p>To log any information, or report an error, the following functions are available:</p>
<ul>
<li><code>node.log("Log")</code></li>
<li><code>node.warn("Warning")</code></li>
<li><code>node.error("Error")</code></li>
</ul>
</p>
<p>The Catch node can also be used to handle errors. To invoke a Catch node,
pass <code>msg</code> as a second argument to <code>node.error</code>:</p>
<pre>node.error("Error",msg)</pre>
<h4>Sending messages</h4>
<p>The function can either return the messages it wants to pass on to the next nodes
in the flow, or can call <code>node.send(messages)</code>.</p>
<p>It can return/send:</p>
<ul>
<li>a single message object - passed to nodes connected to the first output</li>
<li>an array of message objects - passed to nodes connected to the corresponding outputs</li>
</ul>
<p>If any element of the array is itself an array of messages, multiple
messages are sent to the corresponding output.</p>
<p>If null is returned, either by itself or as an element of the array, no
message is passed on.</p>
<p>See the <a target="_new" href="http://nodered.org/docs/writing-functions.html">online documentation</a> for more help.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('run-script', {
category : 'selenium',
defaults : {
name : {
value : ""
},
func : {
value : "console.log(arguments[0].innerHTML);\nreturn msg;"
},
selector : {
value : ""
},
target : {
value : ""
},
timeout : {
value : 1000,
validate : RED.validators.number()
},
waitfor : {
value : 500,
validate : RED.validators.number()
}
},
color : "#d8bfd8",
inputs : 1,
outputs : 1,
icon : "debug.png",
label : function() {
return this.name || "Run Script";
},
labelStyle : function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare : function() {
var that = this;