1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.validationmessagesview;
18
19 import edu.samplu.common.UpgradedSeleniumITBase;
20 import junit.framework.Assert;
21 import org.junit.Test;
22
23
24
25
26 public class ClientErrorsIT extends UpgradedSeleniumITBase {
27 @Override
28 public String getTestUrl() {
29 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
30 }
31
32 @Test
33 public void testClientErrors() throws Exception {
34 fireEvent("name=field1", "focus");
35 waitAndType("name=field1", "");
36 fireEvent("name=field1", "blur");
37 Assert.assertEquals("true", getAttribute("name=field1@aria-invalid"));
38 Assert.assertTrue(getAttribute("name=field1@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
39 Assert.assertTrue(isElementPresent("//textarea[@name='field1']/../../img[@alt='Error']"));
40 fireEvent("name=field1", "focus");
41 for (int second = 0; ; second++) {
42 if (second >= 60) {
43 Assert.fail("timeout");
44 }
45 try {
46 if (isVisible("css=.jquerybubblepopup-innerHtml")) {
47 break;
48 }
49 } catch (Exception e) {
50 }
51 Thread.sleep(1000);
52 }
53
54 Assert.assertTrue(isVisible(
55 "css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"));
56 waitAndType("name=field1", "a");
57 fireEvent("name=field1", "blur");
58 fireEvent("name=field1", "focus");
59 for (int second = 0; ; second++) {
60 if (second >= 60) {
61 Assert.fail("timeout");
62 }
63 try {
64 if (!isVisible("css=.jquerybubblepopup-innerHtml")) {
65 break;
66 }
67 } catch (Exception e) {
68 }
69 Thread.sleep(1000);
70 }
71
72 Assert.assertFalse(isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
73 fireEvent("name=field1", "blur");
74 Assert.assertFalse(isElementPresent("name=field1@aria-invalid"));
75 Assert.assertTrue(getAttribute("name=field1@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
76 Assert.assertFalse(isElementPresent("//textarea[@name='field1']/../img[@alt='Error']"));
77 fireEvent("name=field2", "focus");
78 waitAndType("name=field2", "");
79 fireEvent("name=field2", "blur");
80 Assert.assertEquals("true", getAttribute("name=field2@aria-invalid"));
81 Assert.assertTrue(getAttribute("name=field2@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
82 Assert.assertTrue(isElementPresent("//input[@name='field2']/../img[@alt='Error']"));
83 fireEvent("name=field2", "focus");
84 waitAndType("name=field2", "a");
85 fireEvent("name=field2", "blur");
86 Assert.assertFalse(isElementPresent("name=field2@aria-invalid"));
87 Assert.assertTrue(getAttribute("name=field2@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
88 Assert.assertFalse(isElementPresent("//textarea[@name='field2']/../img[@alt='Error']"));
89 fireEvent("name=field3", "focus");
90 select("name=field3", "");
91 fireEvent("name=field3", "blur");
92 Assert.assertEquals("true", getAttribute("name=field3@aria-invalid"));
93 Assert.assertTrue(getAttribute("name=field3@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
94 Assert.assertTrue(isElementPresent("//select[@name='field3']/../img[@alt='Error']"));
95 fireEvent("name=field3", "focus");
96 select("name=field3", "Option 1");
97 fireEvent("name=field3", "blur");
98 Assert.assertFalse(isElementPresent("name=field3@aria-invalid"));
99 Assert.assertTrue(getAttribute("name=field3@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
100 Assert.assertFalse(isElementPresent("//select[@name='field3']/../img[@alt='Error']"));
101 fireEvent("name=field114", "focus");
102 removeAllSelections("name=field114");
103 fireEvent("name=field114", "blur");
104 Assert.assertEquals("true", getAttribute("name=field114@aria-invalid"));
105 Assert.assertTrue(getAttribute("name=field114@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
106 Assert.assertTrue(isElementPresent("//select[@name='field114']/../img[@alt='Error']"));
107 fireEvent("name=field114", "focus");
108 select("name=field114", "Option 1");
109 fireEvent("name=field114", "blur");
110 Assert.assertFalse(isElementPresent("name=field114@aria-invalid"));
111 Assert.assertTrue(getAttribute("name=field114@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
112 Assert.assertFalse(isElementPresent("//select[@name='field114']/../img[@alt='Error']"));
113 fireEvent("name=field117 value=3", "focus");
114 uncheck("name=field117 value=3");
115 fireEvent("name=field117", "blur");
116 for (int second = 0; ; second++) {
117 if (second >= 60) {
118 Assert.fail("timeout");
119 }
120 try {
121 if (isElementPresent("//input[@name='field117']/../../../img[@alt='Error']")) {
122 break;
123 }
124 } catch (Exception e) {
125 }
126 Thread.sleep(1000);
127 }
128
129 Assert.assertEquals("true", getAttribute("name=field117 value=1@aria-invalid"));
130 Assert.assertTrue(getAttribute("name=field117 value=1@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
131 Assert.assertTrue(isElementPresent("//input[@name='field117']/../../../img[@alt='Error']"));
132 fireEvent("name=field117 value=3", "focus");
133 check("name=field117 value=3");
134 fireEvent("name=field117 value=3", "blur");
135 for (int second = 0; ; second++) {
136 if (second >= 60) {
137 Assert.fail("timeout");
138 }
139 try {
140 if (!isElementPresent("//input[@name='field117']/../../../img[@alt='Error']")) {
141 break;
142 }
143 } catch (Exception e) {
144 }
145 Thread.sleep(1000);
146 }
147
148 Assert.assertFalse(isElementPresent("name=field117 value=1@aria-invalid"));
149 Assert.assertTrue(getAttribute("name=field117 value=3@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
150 Assert.assertFalse(isElementPresent("//input[@name='field117']/../../../img[@alt='Error']"));
151 fireEvent("name=bField1", "focus");
152 uncheck("name=bField1");
153 fireEvent("name=bField1", "blur");
154 Assert.assertEquals("true", getAttribute("name=bField1@aria-invalid"));
155 Assert.assertTrue(getAttribute("name=bField1@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
156 Assert.assertTrue(isElementPresent(
157 "//input[@name='bField1' and following-sibling::img[@alt='Error']]"));
158 fireEvent("name=bField1", "focus");
159 check("name=bField1");
160 fireEvent("name=bField1", "blur");
161 Assert.assertFalse(isElementPresent("name=bField1@aria-invalid"));
162 Assert.assertTrue(getAttribute("name=bField1@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
163 Assert.assertFalse(isElementPresent(
164 "//input[@name='bField1' and following-sibling::img[@alt='Error']]"));
165 fireEvent("name=field115 value=3", "focus");
166 uncheck("name=field115 value=3");
167 uncheck("name=field115 value=4");
168 fireEvent("name=field115", "blur");
169 for (int second = 0; ; second++) {
170 if (second >= 60) {
171 Assert.fail("timeout");
172 }
173 try {
174 if (isElementPresent("//input[@name='field115']/../../../img[@alt='Error']")) {
175 break;
176 }
177 } catch (Exception e) {
178 }
179 Thread.sleep(1000);
180 }
181
182 Assert.assertEquals("true", getAttribute("name=field115 value=1@aria-invalid"));
183 Assert.assertTrue(getAttribute("name=field115 value=1@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
184 Assert.assertTrue(isElementPresent("//input[@name='field115']/../../../img[@alt='Error']"));
185 fireEvent("name=field115 value=3", "focus");
186 check("name=field115 value=3");
187 check("name=field115 value=4");
188 fireEvent("name=field115", "blur");
189 for (int second = 0; ; second++) {
190 if (second >= 60) {
191 Assert.fail("timeout");
192 }
193 try {
194 if (!isElementPresent("//input[@name='field115']/../../../img[@alt='Error']")) {
195 break;
196 }
197 } catch (Exception e) {
198 }
199 Thread.sleep(1000);
200 }
201
202 Assert.assertFalse(isElementPresent("name=field115 value=1@aria-invalid"));
203 Assert.assertFalse(isElementPresent("//input[@name='field115']/../../../img[@alt='Error']"));
204 }
205 }