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