1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.sampleu.krad.compview;
18
19 import com.thoughtworks.selenium.SeleneseTestBase;
20 import org.junit.Test;
21 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
22
23
24
25
26 public class ConstraintsAft extends WebDriverLegacyITBase {
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 waitAndClickByXpath("//ul[@class='nav nav-list']/li[5]/a");
44 waitAndClickByXpath("//a[@id='UifCompView-Navigation3']");
45 }
46
47 protected void testConstraints() throws Exception {
48 checkForIncidentReport("testConstraints");
49
50
51 fireEvent("field10", "focus");
52 waitAndTypeByName("field10", "2");
53 fireEvent("field10", "blur");
54 assertAttributeClassRegexMatches("field10", REGEX_ERROR);
55
56 fireEvent("field10", "focus");
57 clearTextByName("field10");
58 waitAndTypeByName("field10", "51");
59 fireEvent("field10", "blur");
60 assertAttributeClassRegexMatches("field10", REGEX_ERROR);
61
62 fireEvent("field10", "focus");
63 clearTextByName("field10");
64 waitAndTypeByName("field10", "25");
65 fireEvent("field10", "blur");
66 assertAttributeClassRegexMatches("field10", REGEX_VALID);
67
68 waitAndTypeByName("field14", "A");
69 fireEvent("field14", "blur");
70
71 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
72 clearTextByName("field11");
73 waitAndTypeByName("field11", "A");
74 fireEvent("field11", "blur");
75 assertAttributeClassRegexMatches("field11", REGEX_VALID);
76 assertAttributeClassRegexMatches("field14", REGEX_VALID);
77
78 clearTextByName("field11");
79 waitAndTypeByName("field11", "");
80 fireEvent("field11", "blur");
81 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
82
83 clearTextByName("field12");
84 waitAndTypeByName("field12", "A");
85 fireEvent("field12", "blur");
86 assertAttributeClassRegexMatches("field14", REGEX_ERROR);
87
88 clearTextByName("field13");
89 waitAndTypeByName("field13", "A");
90 fireEvent("field13", "blur");
91 assertAttributeClassRegexMatches("field13", REGEX_VALID);
92 assertAttributeClassRegexMatches("field14", REGEX_VALID);
93
94 clearTextByName("field11");
95 waitAndTypeByName("field11", "A");
96 fireEvent("field11", "blur");
97 assertAttributeClassRegexMatches("field11", REGEX_VALID);
98 assertAttributeClassRegexMatches("field14", REGEX_VALID);
99
100 waitAndTypeByName("field18", "A");
101 fireEvent("field18", "blur");
102 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
103
104 waitAndTypeByName("field15", "A");
105 fireEvent("field15", "blur");
106 assertAttributeClassRegexMatches("field15", REGEX_VALID);
107 assertAttributeClassRegexMatches("field18", REGEX_VALID);
108
109 clearTextByName("field15");
110 waitAndTypeByName("field15", "");
111 fireEvent("field15", "blur");
112 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
113
114 clearTextByName("field16");
115 waitAndTypeByName("field16", "A");
116 fireEvent("field16", "blur");
117 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
118
119 clearTextByName("field17");
120 waitAndTypeByName("field17", "A");
121 fireEvent("field17", "blur");
122 assertAttributeClassRegexMatches("field17", REGEX_VALID);
123 assertAttributeClassRegexMatches("field18", REGEX_VALID);
124
125 clearTextByName("field15");
126 waitAndTypeByName("field15", "A");
127 fireEvent("field15", "blur");
128 assertAttributeClassRegexMatches("field18", REGEX_ERROR);
129
130 waitAndTypeByName("field23", "A");
131 fireEvent("field23", "blur");
132 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
133
134 clearTextByName("field19");
135 waitAndTypeByName("field19", "A");
136 fireEvent("field19", "blur");
137 assertAttributeClassRegexMatches("field23", REGEX_VALID);
138
139 clearTextByName("field19");
140 waitAndTypeByName("field19", "");
141 fireEvent("field19", "blur");
142 waitAndTypeByName("field20", "B");
143 fireEvent("field20", "blur");
144 assertAttributeClassRegexMatches("field23", REGEX_VALID);
145
146 clearTextByName("field20");
147 waitAndTypeByName("field20", "");
148 fireEvent("field20", "blur");
149 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
150
151 clearTextByName("field21");
152 waitAndTypeByName("field21", "C");
153 fireEvent("field21", "blur");
154 assertAttributeClassRegexMatches("field23", REGEX_ERROR);
155
156 clearTextByName("field22");
157 waitAndTypeByName("field22", "D");
158 fireEvent("field22", "blur");
159 assertAttributeClassRegexMatches("field23", REGEX_VALID);
160
161 clearTextByName("field19");
162 waitAndTypeByName("field19", "D");
163 fireEvent("field19", "blur");
164 assertAttributeClassRegexMatches("field23", REGEX_VALID);
165
166 clearTextByName("field20");
167 waitAndTypeByName("field20", "D");
168 fireEvent("field20", "blur");
169 assertAttributeClassRegexMatches("field23", REGEX_VALID);
170
171 checkByXpath("//*[@name='field24' and @value='case1']");
172 clearTextByName("field25");
173 waitAndTypeByName("field25", "");
174 fireEvent("field25", "blur");
175 assertAttributeClassRegexMatches("field25", REGEX_ERROR);
176
177 checkByXpath("//*[@name='field24' and @value='case4']");
178 fireEvent("field24", "blur");
179
180 for (int second = 0;; second++) {
181 if (second >= waitSeconds) {
182 SeleneseTestBase.fail("timeout");
183 }
184 try {
185 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_VALID)) {
186 break;
187 }
188 } catch (Exception e) {}
189 Thread.sleep(1000);
190 }
191
192 assertAttributeClassRegexMatches("field25", REGEX_VALID);
193
194 checkByXpath("//*[@name='field24' and @value='case1']");
195 fireEvent("field24", "blur");
196 clearTextByName("field25");
197 waitAndTypeByName("field25", "$100");
198 fireEvent("field25", "blur");
199
200 for (int second = 0;; second++) {
201 if (second >= waitSeconds) {
202 SeleneseTestBase.fail("timeout");
203 }
204 try {
205 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_VALID)) {
206 break;
207 }
208 } catch (Exception e) {}
209 Thread.sleep(1000);
210 }
211
212 assertAttributeClassRegexMatches("field25", REGEX_VALID);
213
214 checkByXpath("//*[@name='field24' and @value='case2']");
215 fireEvent("field24", "blur");
216
217 for (int second = 0;; second++) {
218 if (second >= waitSeconds) {
219 SeleneseTestBase.fail("timeout");
220 }
221 try {
222 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_ERROR)) {
223 break;
224 }
225 } catch (Exception e) {}
226 Thread.sleep(1000);
227 }
228
229 assertAttributeClassRegexMatches("field25", REGEX_ERROR);
230
231 clearTextByName("field25");
232 waitAndTypeByName("field25", "A100");
233 fireEvent("field25", "blur");
234 assertAttributeClassRegexMatches("field25", REGEX_VALID);
235
236 checkByXpath("//*[@name='field24' and @value='case3']");
237 fireEvent("field24", "blur");
238 clearTextByName("field26");
239 waitAndTypeByName("field26", "6000");
240 fireEvent("field26", "blur");
241
242 for (int second = 0;; second++) {
243 if (second >= waitSeconds) {
244 SeleneseTestBase.fail("timeout");
245 }
246 try {
247 if (waitAndGetAttributeByName("field26", "class").matches(REGEX_ERROR)) {
248 break;
249 }
250 } catch (Exception e) {}
251 Thread.sleep(1000);
252 }
253
254 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
255
256 clearTextByName("field26");
257 waitAndTypeByName("field26", "501");
258 fireEvent("field26", "blur");
259 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
260
261 clearTextByName("field26");
262 waitAndTypeByName("field26", "499");
263 fireEvent("field26", "blur");
264 assertAttributeClassRegexMatches("field26", REGEX_VALID);
265
266 clearTextByName("field26");
267 waitAndTypeByName("field26", "6000");
268 fireEvent("field26", "blur");
269 checkByXpath("//*[@name='field24' and @value='case3']");
270 fireEvent("field24", "blur");
271
272 for (int second = 0;; second++) {
273 if (second >= waitSeconds) {
274 SeleneseTestBase.fail("timeout");
275 }
276 try {
277 if (waitAndGetAttributeByName("field26", "class").matches(REGEX_ERROR)) {
278 break;
279 }
280 } catch (Exception e) {}
281 Thread.sleep(1000);
282 }
283
284 assertAttributeClassRegexMatches("field26", REGEX_ERROR);
285
286 checkByXpath("//*[@name='field24' and @value='case4']");
287 clearTextByName("field27");
288 waitAndTypeByName("field27", "A");
289 fireEvent("field27", "blur");
290 clearTextByName("field28");
291 waitAndTypeByName("field28", "");
292 fireEvent("field28", "blur");
293
294 for (int second = 0;; second++) {
295 if (second >= waitSeconds) {
296 SeleneseTestBase.fail("timeout");
297 }
298 try {
299 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_ERROR)) {
300 break;
301 }
302 } catch (Exception e) {}
303 Thread.sleep(1000);
304 }
305
306 assertAttributeClassRegexMatches("field28", REGEX_ERROR);
307
308 checkByXpath("//*[@name='field24' and @value='case3']");
309 fireEvent("field24", "blur");
310
311 for (int second = 0;; second++) {
312 if (second >= waitSeconds) {
313 SeleneseTestBase.fail("timeout");
314 }
315 try {
316 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_VALID)) {
317 break;
318 }
319 } catch (Exception e) {}
320 Thread.sleep(1000);
321 }
322
323 assertAttributeClassRegexMatches("field28", REGEX_VALID);
324
325 clearTextByName("field28");
326 waitAndTypeByName("field28", "B");
327 fireEvent("field28", "blur");
328 checkByXpath("//*[@name='field24' and @value='case4']");
329 fireEvent("field24", "blur");
330
331 for (int second = 0;; second++) {
332 if (second >= waitSeconds) {
333 SeleneseTestBase.fail("timeout");
334 }
335 try {
336 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_VALID)) {
337 break;
338 }
339 } catch (Exception e) {}
340 Thread.sleep(1000);
341 }
342
343 assertAttributeClassRegexMatches("field28", REGEX_VALID);
344
345 clearTextByName("field31");
346 waitAndTypeByName("field31", "B");
347 clearTextByName("field32");
348 waitAndTypeByName("field32", "B");
349 waitAndTypeByName("field33", "");
350 fireEvent("field33", "blur");
351 assertAttributeClassRegexMatches("field33", REGEX_ERROR);
352
353 clearTextByName("field33");
354 waitAndTypeByName("field33", "B");
355 fireEvent("field33", "blur");
356 assertAttributeClassRegexMatches("field33", REGEX_VALID);
357
358 clearTextByName("field32");
359 waitAndTypeByName("field32", "A");
360 clearTextByName("field33");
361 waitAndTypeByName("field33", "");
362 fireEvent("field33", "blur");
363 assertAttributeClassRegexMatches("field33", REGEX_VALID);
364 }
365
366 @Test
367 public void testConstraintsBookmark() throws Exception {
368 testConstraints();
369 passed();
370 }
371
372 @Test
373 public void testConstraintsNav() throws Exception {
374 testConstraints();
375 passed();
376 }
377 }