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