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