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