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