1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.krad.validationmessagesview;
17
18 import com.thoughtworks.selenium.SeleneseTestBase;
19 import org.kuali.rice.testtools.common.JiraAwareFailable;
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21 import org.openqa.selenium.By;
22
23
24
25
26
27
28 public abstract class ClientErrorsAftBase extends WebDriverLegacyITBase {
29
30
31
32
33 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
34
35 @Override
36 public String getBookmarkUrl() {
37 return BOOKMARK_URL;
38 }
39
40
41 protected void navigation() throws InterruptedException {
42 waitAndClickKRAD();
43 waitAndClickByXpath(VALIDATION_FRAMEWORK_DEMO_XPATH);
44 switchToWindow(KUALI_VIEW_WINDOW_TITLE);
45 }
46
47 protected void testClientErrorsNav(JiraAwareFailable failable) throws Exception {
48 navigation();
49 testClientErrors();
50 passed();
51 }
52
53 protected void testClientErrorsBookmark(JiraAwareFailable failable) throws Exception {
54 testClientErrors();
55 passed();
56 }
57
58 protected void testClientErrors() throws Exception {
59 fireEvent("field1", "focus");
60 fireEvent("field1", "blur");
61 Thread.sleep(3000);
62 fireMouseOverEventByName("field1");
63 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByName("field1", "aria-invalid"));
64 assertAttributeClassRegexMatches("field1", REGEX_ERROR);
65 assertTrue(isTextPresent("Required"));
66
67 fireMouseOverEventByName("field1");
68
69 waitIsVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']");
70
71 waitAndTypeByName("field1", "a");
72 fireEvent("field1", "blur");
73 fireMouseOverEventByName("field1");
74
75 waitIsVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']");
76
77 assertFalse(isVisibleByXpath(
78 "//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']"));
79
80 fireEvent("field1", "blur");
81 Thread.sleep(500);
82 assertFalse(isElementPresentByXpath("//*[@name='field1' and @aria-invalid]"));
83 assertAttributeClassRegexMatches("field1", REGEX_VALID);
84 assertTrue("jquerybubblepopup Required not present", isTextPresent("Required"));
85
86 fireEvent("field2", "focus");
87 fireEvent("field2", "blur");
88 fireMouseOverEventByName("field2");
89 Thread.sleep(500);
90
91 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByName("field2", "aria-required"));
92 assertAttributeClassRegexMatches("field2", REGEX_ERROR);
93 assertTrue(isTextPresent("Required"));
94
95 fireEvent("field2", "focus");
96 waitAndTypeByName("field2", "a");
97 fireEvent("field2", "blur");
98 Thread.sleep(500);
99 assertFalse(isElementPresentByXpath("//*[@name='field2' and @aria-invalid]"));
100 assertAttributeClassRegexMatches("field2", REGEX_VALID);
101 assertFalse(isElementPresentByXpath("//textarea[@name='field2']/../img[@alt='Error']"));
102
103 fireEvent("field3", "focus");
104 fireEvent("field3", "blur");
105 fireMouseOverEventByName("field3");
106 Thread.sleep(500);
107 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByName("field3", "aria-invalid"));
108 assertAttributeClassRegexMatches("field3", REGEX_ERROR);
109 assertTrue(isTextPresent("Required"));
110
111 fireEvent("field3", "focus");
112 selectByName("field3", "Option 1");
113 fireEvent("field3", "blur");
114 Thread.sleep(500);
115 assertFalse(isElementPresentByXpath("//*[@name='field3' and @aria-invalid]"));
116 assertAttributeClassRegexMatches("field3", REGEX_VALID);
117 assertFalse(isElementPresentByXpath("//select[@name='field3']/../img[@alt='Error']"));
118
119 fireEvent("field114", "focus");
120 fireMouseOverEventByName("field114");
121 driver.findElement(By.name("field114")).findElements(By.tagName("option")).get(0).click();
122 fireEvent("field114", "blur");
123 Thread.sleep(500);
124 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByName("field114", "aria-invalid"));
125 assertAttributeClassRegexMatches("field114", REGEX_ERROR);
126 assertTrue(isTextPresent("Required"));
127
128 fireEvent("field114", "focus");
129 selectByName("field114", "Option 1");
130 fireEvent("field114", "blur");
131 Thread.sleep(500);
132 assertFalse(isElementPresentByXpath("//*[@name='field114' and @aria-invalid]"));
133 assertAttributeClassRegexMatches("field114", REGEX_VALID);
134 assertFalse(isElementPresentByXpath("//select[@name='field114']/../img[@alt='Error']"));
135
136 fireEvent("field117", "3", "focus");
137 uncheckByXpath("//*[@name='field117' and @value='3']");
138 fireEvent("field117", "blur");
139 fireMouseOverEventByName("field117");
140
141 for (int second = 0;; second++) {
142 if (second >= 10) {
143 SeleneseTestBase.fail(TIMEOUT_MESSAGE);
144 }
145
146 try {
147 if (isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']")) {
148 break;
149 }
150 } catch (Exception e) {}
151
152 Thread.sleep(1000);
153 }
154
155 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByXpath("//*[@name='field117' and @value='1']",
156 "aria-invalid"));
157 assertTrue(waitAndGetAttributeByXpath("//*[@name='field117' and @value='1']", "class").matches(
158 REGEX_ERROR));
159 assertTrue(isTextPresent("Required"));
160
161 fireEvent("field117", "3", "focus");
162 checkByXpath("//*[@name='field117' and @value='3']");
163 fireEvent("field117", "3", "blur");
164
165 for (int second = 0;; second++) {
166 if (second >= waitSeconds) {
167 SeleneseTestBase.fail(TIMEOUT_MESSAGE);
168 }
169
170 try {
171 if (!isElementPresentByXpath("//input[@name='field117']/../../../img[@alt='Error']")) {
172 break;
173 }
174 } catch (Exception e) {}
175
176 Thread.sleep(1000);
177 }
178
179 assertFalse(isElementPresentByXpath("//*[@name='field117' and @value='3' and @aria-invalid]"));
180 assertTrue(waitAndGetAttributeByXpath("//*[@name='field117' and @value='3']", "class").matches(REGEX_VALID));
181 assertFalse(isElementPresentByXpath("//input[@name='field117']/../../../img[@alt='Error']"));
182
183 fireEvent("bField1", "focus");
184 uncheckByName("bField1");
185 fireEvent("bField1", "blur");
186 fireMouseOverEventByName("bField1");
187 Thread.sleep(500);
188 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByName("bField1", "aria-invalid"));
189 assertAttributeClassRegexMatches("bField1", REGEX_ERROR);
190 assertTrue(isTextPresent("Required"));
191
192 fireEvent("bField1", "focus");
193 checkByName("bField1");
194 fireEvent("bField1", "blur");
195 Thread.sleep(500);
196 assertFalse(isElementPresentByXpath("//*[@name='bField1' and @aria-invalid]"));
197 assertAttributeClassRegexMatches("bField1", REGEX_VALID);
198 assertFalse(isElementPresentByXpath("//input[@name='bField1' and following-sibling::img[@alt='Error']]"));
199
200 fireEvent("field115", "3", "focus");
201 uncheckByXpath("//*[@name='field115' and @value='3']");
202 uncheckByXpath("//*[@name='field115' and @value='4']");
203 fireEvent("field115", "blur");
204 fireMouseOverEventByName("field115");
205
206 for (int second = 0;; second++) {
207 if (second >= waitSeconds) {
208 SeleneseTestBase.fail(TIMEOUT_MESSAGE);
209 }
210
211 try {
212 if (isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']")) {
213 break;
214 }
215 } catch (Exception e) {}
216
217 Thread.sleep(1000);
218 }
219
220 SeleneseTestBase.assertEquals("true", waitAndGetAttributeByXpath("//*[@name='field115' and @value='1']",
221 "aria-invalid"));
222 assertTrue(waitAndGetAttributeByXpath("//*[@name='field115' and @value='1']", "class").matches(REGEX_ERROR));
223 assertTrue(isTextPresent("Required"));
224
225 fireEvent("field115", "3", "focus");
226 checkByXpath("//*[@name='field115' and @value='3']");
227 checkByXpath("//*[@name='field115' and @value='4']");
228 fireEvent("field115", "blur");
229
230 for (int second = 0;; second++) {
231 if (second >= waitSeconds) {
232 SeleneseTestBase.fail(TIMEOUT_MESSAGE);
233 }
234
235 try {
236 if (!isElementPresentByXpath("//input[@name='field115']/../../../img[@alt='Error']")) {
237 break;
238 }
239 } catch (Exception e) {}
240
241 Thread.sleep(1000);
242 }
243
244 assertFalse(isElementPresentByXpath("//*[@name='field115' and @value='3' and @aria-invalid]"));
245 assertFalse(isElementPresentByXpath("//input[@name='field115']/../../../img[@alt='Error']"));
246 }
247 }