1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.compview;
18
19 import com.thoughtworks.selenium.SeleneseTestBase;
20 import edu.samplu.common.ITUtil;
21 import edu.samplu.common.SmokeTestBase;
22 import org.junit.Test;
23
24
25
26
27 public class ConstraintsSmokeTest extends SmokeTestBase {
28
29
30
31
32 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
33
34 @Override
35 protected String getBookmarkUrl() {
36 return BOOKMARK_URL;
37 }
38
39 @Override
40 protected void navigate() throws Exception {
41 waitAndClickKRAD();
42 waitAndClickByXpath(KITCHEN_SINK_XPATH);
43 switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH);
44 waitAndClickByLinkText("Validation");
45 }
46
47 protected void testConstraintsField9() throws Exception {
48 testField9FocusBlur();
49 passed();
50 }
51
52 private void testPreRequisiteConstraint() throws Exception {
53 fireEvent("field6", "focus");
54 waitAndTypeByName("field6", "A");
55 fireEvent("field6", "blur");
56 waitAndTypeByName("field7", "");
57 fireEvent("field7", "blur");
58 assertAttributeClassRegexMatches("field7", REGEX_ERROR);
59
60 waitAndTypeByName("field7", "B");
61 fireEvent("field7", "blur");
62 assertAttributeClassRegexMatches("field7", REGEX_VALID);
63
64 waitAndTypeByName("field8", "");
65 fireEvent("field8", "blur");
66 assertAttributeClassRegexMatches("field8", REGEX_ERROR);
67
68 clearTextByName("field8");
69 waitAndTypeByName("field8", "C");
70 fireEvent("field8", "blur");
71 assertAttributeClassRegexMatches("field8", REGEX_VALID);
72
73 clearTextByName("field6");
74 waitAndTypeByName("field6", "");
75 fireEvent("field6", "blur");
76 assertAttributeClassRegexMatches("field6", REGEX_ERROR);
77
78 clearTextByName("field7");
79 waitAndTypeByName("field7", "");
80 fireEvent("field7", "blur");
81 assertAttributeClassRegexMatches("field7", REGEX_VALID);
82
83 clearTextByName("field8");
84 waitAndTypeByName("field8", "");
85 fireEvent("field8", "blur");
86 assertAttributeClassRegexMatches("field6", REGEX_VALID);
87 assertAttributeClassRegexMatches("field7", REGEX_VALID);
88 assertAttributeClassRegexMatches("field8", REGEX_VALID);
89
90 clearTextByName("field8");
91 waitAndTypeByName("field8", "C");
92 fireEvent("field8", "blur");
93 assertAttributeClassRegexMatches("field6", REGEX_ERROR);
94 assertAttributeClassRegexMatches("field7", REGEX_VALID);
95 assertAttributeClassRegexMatches("field8", REGEX_ERROR);
96
97 clearTextByName("field6");
98 waitAndTypeByName("field6", "A");
99 fireEvent("field6", "blur");
100 assertAttributeClassRegexMatches("field6", REGEX_VALID);
101 assertAttributeClassRegexMatches("field7", REGEX_ERROR);
102 assertAttributeClassRegexMatches("field8", REGEX_VALID);
103 passed();
104 }
105
106 private void testField9FocusBlur() throws InterruptedException {
107 fireEvent("field9", "focus");
108 waitAndTypeByName("field9", "1");
109 fireEvent("field9", "blur");
110 assertAttributeClassRegexMatches("field9", REGEX_ERROR);
111
112 fireEvent("field9", "focus");
113 clearTextByName("field9");
114 waitAndTypeByName("field9", "12345");
115 fireEvent("field9", "blur");
116 assertAttributeClassRegexMatches("field9", REGEX_VALID);
117 }
118
119 protected void testConstraints() throws Exception {
120 checkForIncidentReport("testConstraints");
121
122
123 fireEvent("field10", "focus");
124 waitAndTypeByName("field10", "2");
125 fireEvent("field10", "blur");
126 assertAttributeClassRegexMatches("field10", REGEX_ERROR);
127
128 fireEvent("field10", "focus");
129 clearTextByName("field10");
130 waitAndTypeByName("field10", "51");
131 fireEvent("field10", "blur");
132 assertAttributeClassRegexMatches("field10", REGEX_ERROR);
133
134 fireEvent("field10", "focus");
135 clearTextByName("field10");
136 waitAndTypeByName("field10", "25");
137 fireEvent("field10", "blur");
138 assertAttributeClassRegexMatches("field10", REGEX_VALID);
139
140 waitAndTypeByName("field14", "A");
141 fireEvent("field14", "blur");
142
143 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
144 clearTextByName("field11");
145 waitAndTypeByName("field11", "A");
146 fireEvent("field11", "blur");
147 assertAttributeClassRegexMatches("field11", REGEX_VALID);
148 assertAttributeClassRegexMatches("field14", REGEX_VALID);
149
150 clearTextByName("field11");
151 waitAndTypeByName("field11", "");
152 fireEvent("field11", "blur");
153 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
154
155 clearTextByName("field12");
156 waitAndTypeByName("field12", "A");
157 fireEvent("field12", "blur");
158 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
159
160 clearTextByName("field13");
161 waitAndTypeByName("field13", "A");
162 fireEvent("field13", "blur");
163 assertAttributeClassRegexMatches("field13", REGEX_VALID);
164 assertAttributeClassRegexMatches("field14", REGEX_VALID);
165
166 clearTextByName("field11");
167 waitAndTypeByName("field11", "A");
168 fireEvent("field11", "blur");
169 assertAttributeClassRegexMatches("field11", REGEX_VALID);
170 assertAttributeClassRegexMatches("field14", REGEX_VALID);
171
172 waitAndTypeByName("field18", "A");
173 fireEvent("field18", "blur");
174 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
175
176 waitAndTypeByName("field15", "A");
177 fireEvent("field15", "blur");
178 assertAttributeClassRegexMatches("field15", REGEX_VALID);
179 assertAttributeClassRegexMatches("field18", REGEX_VALID);
180
181 clearTextByName("field15");
182 waitAndTypeByName("field15", "");
183 fireEvent("field15", "blur");
184 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
185
186 clearTextByName("field16");
187 waitAndTypeByName("field16", "A");
188 fireEvent("field16", "blur");
189 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
190
191 clearTextByName("field17");
192 waitAndTypeByName("field17", "A");
193 fireEvent("field17", "blur");
194 assertAttributeClassRegexMatches("field17", REGEX_VALID);
195 assertAttributeClassRegexMatches("field18", REGEX_VALID);
196
197 clearTextByName("field15");
198 waitAndTypeByName("field15", "A");
199 fireEvent("field15", "blur");
200 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
201
202 waitAndTypeByName("field23", "A");
203 fireEvent("field23", "blur");
204 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
205
206 clearTextByName("field19");
207 waitAndTypeByName("field19", "A");
208 fireEvent("field19", "blur");
209 assertAttributeClassRegexMatches("field23", REGEX_VALID);
210
211 clearTextByName("field19");
212 waitAndTypeByName("field19", "");
213 fireEvent("field19", "blur");
214 waitAndTypeByName("field20", "B");
215 fireEvent("field20", "blur");
216 assertAttributeClassRegexMatches("field23", REGEX_VALID);
217
218 clearTextByName("field20");
219 waitAndTypeByName("field20", "");
220 fireEvent("field20", "blur");
221 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
222
223 clearTextByName("field21");
224 waitAndTypeByName("field21", "C");
225 fireEvent("field21", "blur");
226 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
227
228 clearTextByName("field22");
229 waitAndTypeByName("field22", "D");
230 fireEvent("field22", "blur");
231 assertAttributeClassRegexMatches("field23", REGEX_VALID);
232
233 clearTextByName("field19");
234 waitAndTypeByName("field19", "D");
235 fireEvent("field19", "blur");
236 assertAttributeClassRegexMatches("field23", REGEX_VALID);
237
238 clearTextByName("field20");
239 waitAndTypeByName("field20", "D");
240 fireEvent("field20", "blur");
241 assertAttributeClassRegexMatches("field23", REGEX_VALID);
242
243 checkByXpath("//*[@name='field24' and @value='case1']");
244 clearTextByName("field25");
245 waitAndTypeByName("field25", "");
246 fireEvent("field25", "blur");
247 assertAttributeClassRegexMatches("field25", REGEX_ERROR);
248
249 checkByXpath("//*[@name='field24' and @value='case4']");
250 fireEvent("field24", "blur");
251
252 for (int second = 0;; second++) {
253 if (second >= waitSeconds) {
254 SeleneseTestBase.fail("timeout");
255 }
256 try {
257 if (getAttributeByName("field25", "class").matches(REGEX_VALID)) {
258 break;
259 }
260 } catch (Exception e) {}
261 Thread.sleep(1000);
262 }
263
264 assertAttributeClassRegexMatches("field25", REGEX_VALID);
265
266 checkByXpath("//*[@name='field24' and @value='case1']");
267 fireEvent("field24", "blur");
268 clearTextByName("field25");
269 waitAndTypeByName("field25", "$100");
270 fireEvent("field25", "blur");
271
272 for (int second = 0;; second++) {
273 if (second >= waitSeconds) {
274 SeleneseTestBase.fail("timeout");
275 }
276 try {
277 if (getAttributeByName("field25", "class").matches(REGEX_VALID)) {
278 break;
279 }
280 } catch (Exception e) {}
281 Thread.sleep(1000);
282 }
283
284 assertAttributeClassRegexMatches("field25", REGEX_VALID);
285
286 checkByXpath("//*[@name='field24' and @value='case2']");
287 fireEvent("field24", "blur");
288
289 for (int second = 0;; second++) {
290 if (second >= waitSeconds) {
291 SeleneseTestBase.fail("timeout");
292 }
293 try {
294 if (getAttributeByName("field25", "class").matches(REGEX_ERROR)) {
295 break;
296 }
297 } catch (Exception e) {}
298 Thread.sleep(1000);
299 }
300
301 assertAttributeClassRegexMatches("field25", REGEX_ERROR);
302
303 clearTextByName("field25");
304 waitAndTypeByName("field25", "A100");
305 fireEvent("field25", "blur");
306 assertAttributeClassRegexMatches("field25", REGEX_VALID);
307
308 checkByXpath("//*[@name='field24' and @value='case3']");
309 fireEvent("field24", "blur");
310 clearTextByName("field26");
311 waitAndTypeByName("field26", "6000");
312 fireEvent("field26", "blur");
313
314 for (int second = 0;; second++) {
315 if (second >= waitSeconds) {
316 SeleneseTestBase.fail("timeout");
317 }
318 try {
319 if (getAttributeByName("field26", "class").matches(REGEX_ERROR)) {
320 break;
321 }
322 } catch (Exception e) {}
323 Thread.sleep(1000);
324 }
325
326 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
327
328 clearTextByName("field26");
329 waitAndTypeByName("field26", "501");
330 fireEvent("field26", "blur");
331 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
332
333 clearTextByName("field26");
334 waitAndTypeByName("field26", "499");
335 fireEvent("field26", "blur");
336 assertAttributeClassRegexMatches("field26", REGEX_VALID);
337
338 clearTextByName("field26");
339 waitAndTypeByName("field26", "6000");
340 fireEvent("field26", "blur");
341 checkByXpath("//*[@name='field24' and @value='case3']");
342 fireEvent("field24", "blur");
343
344 for (int second = 0;; second++) {
345 if (second >= waitSeconds) {
346 SeleneseTestBase.fail("timeout");
347 }
348 try {
349 if (getAttributeByName("field26", "class").matches(REGEX_ERROR)) {
350 break;
351 }
352 } catch (Exception e) {}
353 Thread.sleep(1000);
354 }
355
356 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
357
358 checkByXpath("//*[@name='field24' and @value='case4']");
359 clearTextByName("field27");
360 waitAndTypeByName("field27", "A");
361 fireEvent("field27", "blur");
362 clearTextByName("field28");
363 waitAndTypeByName("field28", "");
364 fireEvent("field28", "blur");
365
366 for (int second = 0;; second++) {
367 if (second >= waitSeconds) {
368 SeleneseTestBase.fail("timeout");
369 }
370 try {
371 if (getAttributeByName("field28", "class").matches(REGEX_ERROR)) {
372 break;
373 }
374 } catch (Exception e) {}
375 Thread.sleep(1000);
376 }
377
378 assertAttributeClassRegexMatches("field28", REGEX_ERROR);
379
380 checkByXpath("//*[@name='field24' and @value='case3']");
381 fireEvent("field24", "blur");
382
383 for (int second = 0;; second++) {
384 if (second >= waitSeconds) {
385 SeleneseTestBase.fail("timeout");
386 }
387 try {
388 if (getAttributeByName("field28", "class").matches(REGEX_VALID)) {
389 break;
390 }
391 } catch (Exception e) {}
392 Thread.sleep(1000);
393 }
394
395 assertAttributeClassRegexMatches("field28", REGEX_VALID);
396
397 clearTextByName("field28");
398 waitAndTypeByName("field28", "B");
399 fireEvent("field28", "blur");
400 checkByXpath("//*[@name='field24' and @value='case4']");
401 fireEvent("field24", "blur");
402
403 for (int second = 0;; second++) {
404 if (second >= waitSeconds) {
405 SeleneseTestBase.fail("timeout");
406 }
407 try {
408 if (getAttributeByName("field28", "class").matches(REGEX_VALID)) {
409 break;
410 }
411 } catch (Exception e) {}
412 Thread.sleep(1000);
413 }
414
415 assertAttributeClassRegexMatches("field28", REGEX_VALID);
416
417 clearTextByName("field31");
418 waitAndTypeByName("field31", "B");
419 clearTextByName("field32");
420 waitAndTypeByName("field32", "B");
421 waitAndTypeByName("field33", "");
422 fireEvent("field33", "blur");
423 assertAttributeClassRegexMatches("field33", REGEX_ERROR);
424
425 clearTextByName("field33");
426 waitAndTypeByName("field33", "B");
427 fireEvent("field33", "blur");
428 assertAttributeClassRegexMatches("field33", REGEX_VALID);
429
430 clearTextByName("field32");
431 waitAndTypeByName("field32", "A");
432 clearTextByName("field33");
433 waitAndTypeByName("field33", "");
434 fireEvent("field33", "blur");
435 assertAttributeClassRegexMatches("field33", REGEX_VALID);
436 }
437
438 @Test
439 public void testConstraintsBookmark() throws Exception {
440 testConstraints();
441 passed();
442 }
443
444 @Test
445 public void testConstraintsField9Bookmark() throws Exception {
446 testConstraintsField9();
447 passed();
448 }
449
450 @Test
451 public void testPreRequisiteConstraintBookmark() throws Exception {
452 testPreRequisiteConstraint();
453 passed();
454 }
455
456 @Test
457 public void testConstraintsNav() throws Exception {
458 testConstraints();
459 passed();
460 }
461
462 @Test
463 public void testConstraintsField9Nav() throws Exception {
464 testConstraintsField9();
465 passed();
466 }
467
468 @Test
469 public void testPreRequisiteConstraintNav() throws Exception {
470 testPreRequisiteConstraint();
471 passed();
472 }
473 }