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