1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.travel.krad.test;
17
18 import edu.samplu.common.WebDriverLegacyITBase;
19 import org.junit.Assert;
20 import org.junit.Test;
21
22
23
24
25
26
27 public class UIFComponentValidationRegexPatternLegacyIT extends WebDriverLegacyITBase {
28
29 @Override
30 public String getTestUrl() {
31 return "/kr-krad/uicomponents?viewId=UifCompView_KNS&methodToCall=start&readOnlyFields=field91";
32 }
33
34 @Test
35 public void testValidCharacterConstraint() throws Exception {
36
37
38
39
40
41
42
43
44 waitAndClickByXpath("//a[contains(text(),'Validation - Regex')]");
45
46
47
48
49 waitAndTypeByName("field50", "123.123");
50 fireEvent("field50","blur");
51 validateErrorImage(true);
52 clearTextByName("field50");
53
54 waitAndTypeByXpath("//input[@name='field50']", "1234.4");
55 fireEvent("field50","blur");
56 validateErrorImage(true);
57 clearTextByName("field50");
58
59
60 waitAndTypeByXpath("//input[@name='field50']", "1234.434");
61 fireEvent("field50","blur");
62 validateErrorImage(true);
63 clearTextByName("field50");
64
65 waitAndTypeByXpath("//input[@name='field50']", "123.67");
66 fireEvent("field50","blur");
67 validateErrorImage(false);
68 clearTextByName("field50");
69
70
71
72 waitAndTypeByXpath("//input[@name='field51']", "127.");
73 fireEvent("field51","blur");
74 validateErrorImage(true);
75 clearTextByName("field51");
76
77 waitAndTypeByXpath("//input[@name='field51']", "1234()98");
78 fireEvent("field51","blur");
79 validateErrorImage(true);
80 clearTextByName("field51");
81
82 waitAndTypeByXpath("//input[@name='field51']", "-123.67");
83 fireEvent("field51","blur");
84 validateErrorImage(false);
85 clearTextByName("field51");
86
87
88
89 waitAndTypeByXpath("//input[@name='field77']", "127.");
90 fireEvent("field77","blur");
91 validateErrorImage(true);
92 clearTextByName("field77");
93
94 waitAndTypeByXpath("//input[@name='field77']", "1234.4123");
95 fireEvent("field77","blur");
96 validateErrorImage(true);
97 clearTextByName("field77");
98
99 waitAndTypeByXpath("//input[@name='field77']", "123E123");
100 fireEvent("field77", "blur");
101 validateErrorImage(true);
102 clearTextByName("field77");
103
104 waitAndTypeByXpath("//input[@name='field77']", "-123");
105 fireEvent("field77", "blur");
106 validateErrorImage(false);
107 clearTextByName("field77");
108
109
110 waitAndTypeByXpath("//input[@name='field52']", "1271231234");
111 fireEvent("field52", "blur");
112 validateErrorImage(true);
113 clearTextByName("field52");
114
115 waitAndTypeByXpath("//input[@name='field52']", "123-123-123");
116 fireEvent("field52", "blur");
117 validateErrorImage(true);
118 clearTextByName("field52");
119
120 waitAndTypeByXpath("//input[@name='field52']", "12-12-123445");
121 fireEvent("field52", "blur");
122 validateErrorImage(true);
123 clearTextByName("field52");
124
125 waitAndTypeByXpath("//input[@name='field52']", "1234-12-1234");
126 fireEvent("field52", "blur");
127 validateErrorImage(true);
128 clearTextByName("field52");
129
130 waitAndTypeByXpath("//input[@name='field52']", "123.123.1234");
131 fireEvent("field52", "blur");
132 validateErrorImage(true);
133 clearTextByName("field52");
134
135 waitAndTypeByXpath("//input[@name='field52']", "123-123-12345");
136 fireEvent("field52", "blur");
137 validateErrorImage(true);
138 clearTextByName("field52");
139
140 waitAndTypeByXpath("//input[@name='field52']", "123-123-1234");
141 fireEvent("field52", "blur");
142 validateErrorImage(false);
143 clearTextByName("field52");
144
145
146 waitAndTypeByXpath("//input[@name='field53']", "127");
147 fireEvent("field53", "blur");
148 validateErrorImage(true);
149 clearTextByName("field53");
150
151 waitAndTypeByXpath("//input[@name='field53']", "TestJava!@#Class");
152 fireEvent("field53", "blur");
153 validateErrorImage(true);
154 clearTextByName("field53");
155
156 waitAndTypeByXpath("//input[@name='field53']", "Test JavaClass");
157 fireEvent("field53", "blur");
158 validateErrorImage(true);
159 clearTextByName("field53");
160
161 waitAndTypeByXpath("//input[@name='field53']", "Test JavaClass");
162 fireEvent("field53", "blur");
163 validateErrorImage(true);
164 clearTextByName("field53");
165
166 waitAndTypeByXpath("//input[@name='field53']", "TestJavaClass");
167 fireEvent("field53", "blur");
168 validateErrorImage(false);
169 clearTextByName("field53");
170
171
172 waitAndTypeByXpath("//input[@name='field54']", "123@123.123");
173 fireEvent("field54", "blur");
174 validateErrorImage(true);
175 clearTextByName("field54");
176
177 waitAndTypeByXpath("//input[@name='field54']", "email.com@emailServer");
178 fireEvent("field54", "blur");
179 validateErrorImage(true);
180 clearTextByName("field54");
181
182 waitAndTypeByXpath("//input[@name='field54']", "emailemailServer@.com");
183 fireEvent("field54", "blur");
184 validateErrorImage(true);
185 clearTextByName("field54");
186
187 waitAndTypeByXpath("//input[@name='field54']", "email@emailServercom");
188 fireEvent("field54", "blur");
189 validateErrorImage(true);
190 clearTextByName("field54");
191
192 waitAndTypeByXpath("//input[@name='field54']", "email@emailServer.com");
193 fireEvent("field54", "blur");
194 validateErrorImage(false);
195 clearTextByName("field54");
196
197
198 waitAndTypeByXpath("//input[@name='field84']", "www.google.com");
199 fireEvent("field84", "blur");
200 validateErrorImage(true);
201 clearTextByName("field84");
202
203 waitAndTypeByXpath("//input[@name='field84']", "https:www.google.com");
204 fireEvent("field84", "blur");
205 validateErrorImage(true);
206 clearTextByName("field84");
207
208 waitAndTypeByXpath("//input[@name='field84']", "ftp://www.google.comsdfa123!#@");
209 fireEvent("field84", "blur");
210 validateErrorImage(true);
211 clearTextByName("field84");
212
213 waitAndTypeByXpath("//input[@name='field84']", "ftp:/www.google.coms");
214 fireEvent("field84", "blur");
215 validateErrorImage(true);
216 clearTextByName("field84");
217
218 waitAndTypeByXpath("//input[@name='field84']", "ftp://www.google.com");
219 fireEvent("field84", "blur");
220 validateErrorImage(false);
221 clearTextByName("field84");
222
223 waitAndTypeByXpath("//input[@name='field84']", "https://www.google.com");
224 fireEvent("field84", "blur");
225 validateErrorImage(false);
226 clearTextByName("field84");
227
228 waitAndTypeByXpath("//input[@name='field84']", "http://www.google.com");
229 fireEvent("field84", "blur");
230 validateErrorImage(false);
231 clearTextByName("field84");
232
233
234
235 waitAndTypeByXpath("//input[@name='field55']", "12/12/2112 12:12:87 am");
236 fireEvent("field55", "blur");
237 validateErrorImage(true);
238 clearTextByName("field55");
239
240 waitAndTypeByXpath("//input[@name='field55']", "12-12-2112 12:12 am");
241 fireEvent("field55", "blur");
242 validateErrorImage(true);
243 clearTextByName("field55");
244
245 waitAndTypeByXpath("//input[@name='field55']", "12-12-2112 12:12");
246 fireEvent("field55", "blur");
247 validateErrorImage(true);
248 clearTextByName("field55");
249
250 waitAndTypeByXpath("//input[@name='field55']", "12/12/2112 12:12");
251 fireEvent("field55", "blur");
252 validateErrorImage(true);
253 clearTextByName("field55");
254
255 waitAndTypeByXpath("//input[@name='field55']", "12-12-2112 12:12:78");
256 fireEvent("field55", "blur");
257 validateErrorImage(true);
258 clearTextByName("field55");
259
260 waitAndTypeByXpath("//input[@name='field55']", "12 Sept");
261 fireEvent("field55", "blur");
262 validateErrorImage(true);
263 clearTextByName("field55");
264
265 waitAndTypeByXpath("//input[@name='field55']", "Sept 12 12:12");
266 fireEvent("field55", "blur");
267 validateErrorImage(true);
268 clearTextByName("field55");
269
270 waitAndTypeByXpath("//input[@name='field55']", "221299 12:12:13");
271 fireEvent("field55", "blur");
272 validateErrorImage(true);
273 clearTextByName("field55");
274
275 waitAndTypeByXpath("//input[@name='field55']", "111222 12:12");
276 fireEvent("field55", "blur");
277 validateErrorImage(true);
278 clearTextByName("field55");
279
280 waitAndTypeByXpath("//input[@name='field55']", "9/9/2012 12:12 am");
281 fireEvent("field55", "blur");
282 validateErrorImage(true);
283 clearTextByName("field55");
284
285
286 waitAndTypeByXpath("//input[@name='field55']", "09/09/2012 12:12 pm");
287 fireEvent("field55", "blur");
288 validateErrorImage(false);
289 clearTextByName("field55");
290
291 waitAndTypeByXpath("//input[@name='field55']", "090923");
292 fireEvent("field55", "blur");
293 validateErrorImage(false);
294 clearTextByName("field55");
295
296 waitAndTypeByXpath("//input[@name='field55']", "Sept 12");
297 fireEvent("field55", "blur");
298 validateErrorImage(false);
299 clearTextByName("field55");
300
301 waitAndTypeByXpath("//input[@name='field55']", "2034");
302 fireEvent("field55", "blur");
303 validateErrorImage(false);
304 clearTextByName("field55");
305
306 waitAndTypeByXpath("//input[@name='field55']", "12/12/2012 23:12:59");
307 fireEvent("field55", "blur");
308 validateErrorImage(false);
309 clearTextByName("field55");
310
311 waitAndTypeByXpath("//input[@name='field55']", "12-12-12 23:12:59");
312 fireEvent("field55", "blur");
313 validateErrorImage(false);
314 clearTextByName("field55");
315
316 waitAndTypeByXpath("//input[@name='field55']", "121212 23:12:32");
317 fireEvent("field55", "blur");
318 validateErrorImage(false);
319 clearTextByName("field55");
320
321 waitAndTypeByXpath("//input[@name='field55']", "Sept 12 23:45:50");
322 fireEvent("field55", "blur");
323 validateErrorImage(false);
324 clearTextByName("field55");
325
326 waitAndTypeByXpath("//input[@name='field55']", "2011 12:23:32");
327 fireEvent("field55", "blur");
328 validateErrorImage(false);
329 clearTextByName("field55");
330
331
332 waitAndTypeByXpath("//input[@name='field75']", "12122012");
333 fireEvent("field75", "blur");
334 validateErrorImage(true);
335 clearTextByName("field75");
336
337 waitAndTypeByXpath("//input[@name='field75']", "13-12-34");
338 fireEvent("field75", "blur");
339 validateErrorImage(true);
340 clearTextByName("field75");
341
342 waitAndTypeByXpath("//input[@name='field75']", "12:12:2034");
343 fireEvent("field75", "blur");
344 validateErrorImage(true);
345 clearTextByName("field75");
346
347 waitAndTypeByXpath("//input[@name='field75']", "12-12-2034");
348 fireEvent("field75", "blur");
349 validateErrorImage(false);
350 clearTextByName("field75");
351
352
353 waitAndTypeByXpath("//input[@name='field82']", "13:00:12");
354 fireEvent("field82", "blur");
355 validateErrorImage(true);
356 clearTextByName("field82");
357
358 waitAndTypeByXpath("//input[@name='field82']", "09:00:");
359 fireEvent("field82", "blur");
360 validateErrorImage(true);
361 clearTextByName("field82");
362
363 waitAndTypeByXpath("//input[@name='field82']", "3-00:12");
364 fireEvent("field82", "blur");
365 validateErrorImage(true);
366 clearTextByName("field82");
367
368 waitAndTypeByXpath("//input[@name='field82']", "3:00:34");
369 fireEvent("field82", "blur");
370 validateErrorImage(false);
371 clearTextByName("field82");
372
373 waitAndTypeByXpath("//input[@name='field82']", "3:00");
374 fireEvent("field82", "blur");
375 validateErrorImage(false);
376 clearTextByName("field82");
377
378
379 waitAndTypeByXpath("//input[@name='field83']", "24:00:12");
380 fireEvent("field83", "blur");
381 validateErrorImage(true);
382 clearTextByName("field83");
383
384 waitAndTypeByXpath("//input[@name='field83']", "14:00:");
385 fireEvent("field83", "blur");
386 validateErrorImage(true);
387 clearTextByName("field83");
388
389 waitAndTypeByXpath("//input[@name='field83']", "13:00:76");
390 fireEvent("field83", "blur");
391 validateErrorImage(true);
392 clearTextByName("field83");
393
394 waitAndTypeByXpath("//input[@name='field83']", "13:00:23");
395 fireEvent("field83", "blur");
396 validateErrorImage(false);
397 clearTextByName("field83");
398
399 waitAndTypeByXpath("//input[@name='field83']", "23:00:12");
400 fireEvent("field83", "blur");
401 validateErrorImage(false);
402 clearTextByName("field83");
403
404
405 waitAndTypeByXpath("//input[@name='field56']", "1000-12-12 12:12:12.103");
406 fireEvent("field56", "blur");
407 validateErrorImage(true);
408 clearTextByName("field56");
409
410 waitAndTypeByXpath("//input[@name='field56']", "2000/12/12 12-12-12.87");
411 fireEvent("field56", "blur");
412 validateErrorImage(true);
413 clearTextByName("field56");
414
415 waitAndTypeByXpath("//input[@name='field56']", "2000/12/12 12-12-12.87");
416 fireEvent("field56", "blur");
417 validateErrorImage(true);
418 clearTextByName("field56");
419
420 waitAndTypeByXpath("//input[@name='field56']", "2011-08-12 12:12:12");
421 fireEvent("field56", "blur");
422 validateErrorImage(true);
423 clearTextByName("field56");
424
425
426
427
428
429
430
431
432
433
434 waitAndTypeByXpath("//input[@name='field56']", "2099-12-12 12:12:12.103");
435 fireEvent("field56", "blur");
436 validateErrorImage(false);
437 clearTextByName("field56");
438
439
440 waitAndTypeByXpath("//input[@name='field57']", "1599");
441 fireEvent("field57", "blur");
442 validateErrorImage(true);
443 clearTextByName("field57");
444
445 waitAndTypeByXpath("//input[@name='field57']", "2200");
446 fireEvent("field57", "blur");
447 validateErrorImage(true);
448 clearTextByName("field57");
449
450 waitAndTypeByXpath("//input[@name='field57']", "20000");
451 fireEvent("field57", "blur");
452 validateErrorImage(true);
453 clearTextByName("field57");
454
455 waitAndTypeByXpath("//input[@name='field57']", "-202");
456 fireEvent("field57", "blur");
457 validateErrorImage(true);
458 clearTextByName("field57");
459
460 waitAndTypeByXpath("//input[@name='field57']", "2000");
461 fireEvent("field57", "blur");
462 validateErrorImage(false);
463 clearTextByName("field57");
464
465
466 waitAndTypeByXpath("//input[@name='field58']", "0");
467 fireEvent("field58", "blur");
468 validateErrorImage(true);
469 clearTextByName("field58");
470
471 waitAndTypeByXpath("//input[@name='field58']", "-12");
472 fireEvent("field58", "blur");
473 validateErrorImage(true);
474 clearTextByName("field58");
475
476 waitAndTypeByXpath("//input[@name='field58']", "100");
477 fireEvent("field58", "blur");
478 validateErrorImage(true);
479 clearTextByName("field58");
480
481 waitAndTypeByXpath("//input[@name='field58']", "12");
482 fireEvent("field58", "blur");
483 validateErrorImage(false);
484 clearTextByName("field58");
485
486
487
488 waitAndTypeByXpath("//input[@name='field61']", "123");
489 fireEvent("field61", "blur");
490 validateErrorImage(true);
491 clearTextByName("field61");
492
493 waitAndTypeByXpath("//input[@name='field61']", "2341 12");
494 fireEvent("field61", "blur");
495 validateErrorImage(true);
496 clearTextByName("field61");
497
498 waitAndTypeByXpath("//input[@name='field61']", "0-1231");
499 fireEvent("field61", "blur");
500 validateErrorImage(true);
501 clearTextByName("field61");
502
503 waitAndTypeByXpath("//input[@name='field61']", "12345");
504 fireEvent("field61", "blur");
505 validateErrorImage(false);
506 clearTextByName("field61");
507
508
509 waitAndTypeByXpath("//input[@name='field62']", "123 23 @#");
510 fireEvent("field62", "blur");
511 validateErrorImage(true);
512 clearTextByName("field62");
513
514 waitAndTypeByXpath("//input[@name='field62']", "-asd123");
515 fireEvent("field62", "blur");
516 validateErrorImage(true);
517 clearTextByName("field62");
518
519 waitAndTypeByXpath("//input[@name='field62']", "asd/123");
520 fireEvent("field62", "blur");
521 validateErrorImage(true);
522 clearTextByName("field62");
523
524 waitAndTypeByXpath("//input[@name='field62']", "asd123");
525 fireEvent("field62", "blur");
526 validateErrorImage(false);
527 clearTextByName("field62");
528
529
530 waitAndTypeByXpath("//input[@name='field63']", "123^we");
531 fireEvent("field63", "blur");
532 validateErrorImage(true);
533 clearTextByName("field63");
534
535 waitAndTypeByXpath("//input[@name='field63']", "-123_asd");
536 fireEvent("field63", "blur");
537 validateErrorImage(true);
538 clearTextByName("field63");
539
540 waitAndTypeByXpath("//input[@name='field63']", "123 23 @#");
541 fireEvent("field63", "blur");
542 clearTextByName("field63");
543
544 waitAndTypeByXpath("//input[@name='field63']", "as_de 456/123");
545 fireEvent("field63", "blur");
546 validateErrorImage(false);
547 clearTextByName("field63");
548
549
550 waitAndTypeByXpath("//input[@name='field64']", "123^we");
551 fireEvent("field64", "blur");
552 validateErrorImage(true);
553 clearTextByName("field64");
554
555 waitAndTypeByXpath("//input[@name='field64']", "asd_pqr");
556 fireEvent("field64", "blur");
557 validateErrorImage(true);
558 clearTextByName("field64");
559
560 waitAndTypeByXpath("//input[@name='field64']", "asd/def");
561 fireEvent("field64", "blur");
562 validateErrorImage(true);
563 clearTextByName("field64");
564
565 waitAndTypeByXpath("//input[@name='field64']", "asd ,pqr");
566 fireEvent("field64", "blur");
567 validateErrorImage(false);
568 clearTextByName("field64");
569
570
571 waitAndTypeByXpath("//input[@name='field76']", "123");
572 fireEvent("field76", "blur");
573 validateErrorImage(true);
574 clearTextByName("field76");
575
576 waitAndTypeByXpath("//input[@name='field76']", "`abcd`");
577 fireEvent("field76", "blur");
578 validateErrorImage(true);
579 clearTextByName("field76");
580
581 waitAndTypeByXpath("//input[@name='field76']", "|abcd|");
582 fireEvent("field76", "blur");
583 validateErrorImage(true);
584 clearTextByName("field76");
585
586 waitAndTypeByXpath("//input[@name='field76']", "~abcd~");
587 fireEvent("field76", "blur");
588 validateErrorImage(true);
589 clearTextByName("field76");
590
591 waitAndTypeByXpath("//input[@name='field76']", " ab_c d_ef ");
592 fireEvent("field76", "blur");
593 validateErrorImage(false);
594 clearTextByName("field76");
595
596
597 waitAndTypeByXpath("//input[@name='field65']", "123 ^we");
598 fireEvent("field65", "blur");
599 validateErrorImage(true);
600 clearTextByName("field65");
601
602 waitAndTypeByXpath("//input[@name='field65']", "123^we!@#^&*~:");
603 fireEvent("field65", "blur");
604 validateErrorImage(false);
605 clearTextByName("field65");
606
607
608 waitAndTypeByXpath("//input[@name='field66']", "123 ^we");
609 fireEvent("field66", "blur");
610 validateErrorImage(true);
611 clearTextByName("field66");
612
613 waitAndTypeByXpath("//input[@name='field66']", "123_^we");
614 fireEvent("field66", "blur");
615 validateErrorImage(true);
616 clearTextByName("field66");
617
618 waitAndTypeByXpath("//input[@name='field66']", "abc ABC");
619 fireEvent("field66", "blur");
620 validateErrorImage(true);
621 clearTextByName("field66");
622
623 waitAndTypeByXpath("//input[@name='field66']", "aAbBcC");
624 fireEvent("field66", "blur");
625 validateErrorImage(false);
626 clearTextByName("field66");
627
628
629 waitAndTypeByXpath("//input[@name='field67']", "123 ^we");
630 fireEvent("field67", "blur");
631 validateErrorImage(true);
632 clearTextByName("field67");
633
634 waitAndTypeByXpath("//input[@name='field67']", "123/10");
635 fireEvent("field67", "blur");
636 validateErrorImage(true);
637 clearTextByName("field67");
638
639 waitAndTypeByXpath("//input[@name='field67']", "(123.00)");
640 fireEvent("field67", "blur");
641 validateErrorImage(true);
642 clearTextByName("field67");
643
644 waitAndTypeByXpath("//input[@name='field67']", "(12-3)");
645 fireEvent("field67", "blur");
646 validateErrorImage(false);
647 clearTextByName("field67");
648
649
650 waitAndTypeByXpath("//input[@name='field68']", "123.123");
651 fireEvent("field68", "blur");
652 validateErrorImage(true);
653 clearTextByName("field68");
654
655 waitAndTypeByXpath("//input[@name='field68']", "a.b");
656 fireEvent("field68", "blur");
657 validateErrorImage(true);
658 clearTextByName("field68");
659
660 waitAndTypeByXpath("//input[@name='field68']", "123 qwe");
661 fireEvent("field68", "blur");
662 validateErrorImage(true);
663 clearTextByName("field68");
664
665 waitAndTypeByXpath("//input[@name='field68']", "5.a");
666 fireEvent("field68", "blur");
667 validateErrorImage(true);
668 clearTextByName("field68");
669
670 waitAndTypeByXpath("//input[@name='field68']", "a.0,b.4");
671 fireEvent("field68", "blur");
672 validateErrorImage(true);
673 clearTextByName("field68");
674
675 waitAndTypeByXpath("//input[@name='field68']", "a.0");
676 fireEvent("field68", "blur");
677 validateErrorImage(false);
678 clearTextByName("field68");
679 passed();
680 }
681
682 public void validateErrorImage(boolean validateVisible) throws Exception {
683 Thread.sleep(500);
684 for (int second = 0;; second++) {
685 if (second >= 5)
686 Assert.fail("timeout");
687 try {
688 if (validateVisible) {
689
690 if (isVisible("img.uif-validationImage"));
691 break;
692 } else {
693
694 if (! isVisible("img.uif-validationImage"))
695 break;
696 }
697
698 } catch (Exception e) {}
699 Thread.sleep(1000);
700 }
701 if (validateVisible) {
702 Assert.assertTrue(isVisible("img.uif-validationImage"));
703 } else {
704 Assert.assertTrue(! isVisible("img.uif-validationImage"));
705 }
706 }
707 }