1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.controls;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.demo.uif.library.DemoLibraryBase;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.Keys;
22 import org.openqa.selenium.WebElement;
23
24
25
26
27 public class DemoControlCheckboxDefaultAft extends DemoLibraryBase {
28
29
30
31
32 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CheckboxControlView";
33
34 @Override
35 public String getBookmarkUrl() {
36 return BOOKMARK_URL;
37 }
38
39 @Override
40 protected void navigate() throws Exception {
41 navigateToExample("Demo-CheckboxControl-Example1");
42 }
43
44 protected void testCheckboxControlDefault() throws Exception {
45 waitForElementPresentById("ST-DemoCheckboxControlExample1-Input1_control");
46 assertTextPresent("Default Checkbox Control");
47 assertLabelFor("ST-DemoCheckboxControlExample1-Input1_control", "Add me to your mailing list");
48 assertTrue(isVisibleById("ST-DemoCheckboxControlExample1-Input1_control"));
49 assertTrue(isEnabledById("ST-DemoCheckboxControlExample1-Input1_control"));
50 assertFalse(isCheckedById("ST-DemoCheckboxControlExample1-Input1_control"));
51 checkById("ST-DemoCheckboxControlExample1-Input1_control");
52 assertTrue(isCheckedById("ST-DemoCheckboxControlExample1-Input1_control"));
53 }
54
55
56 @Test
57 public void testCheckboxControlDefaultBookmark() throws Exception {
58 testCheckboxControlDefault();
59 passed();
60 }
61
62 @Test
63 public void testCheckboxControlDefaultNav() throws Exception {
64 navigateToLibraryDemo("Controls", "Checkbox");
65 testCheckboxControlDefault();
66 passed();
67 }
68
69 protected void testCheckboxControlOptionsFinder() throws Exception {
70 navigateToExample("Demo-CheckboxControl-Example2");
71
72 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_0");
73 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_1");
74 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_2");
75 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_3");
76 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_4");
77 assertTextPresent("CheckboxControl with optionsFinder set");
78 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_0", "Option 1");
79 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_1", "Option 2");
80 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_2", "Option 3");
81 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_3", "Disabled Option 4");
82 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_4", "Option 5");
83
84
85 assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_0"));
86 assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_1"));
87 assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_2"));
88 assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_3"));
89 assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_4"));
90 assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_0"));
91 assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_1"));
92 assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_2"));
93 assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_3"));
94 assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_4"));
95 assertFalse("Checkbox ST-DemoCheckboxControlExample2-Input1_control_0 is checked", isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_0"));
96 assertFalse("Checkbox ST-DemoCheckboxControlExample2-Input1_control_1 is checked", isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_1"));
97 assertFalse("Checkbox ST-DemoCheckboxControlExample2-Input1_control_2 is checked", isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_2"));
98 assertFalse("Checkbox ST-DemoCheckboxControlExample2-Input1_control_3 is checked", isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_3"));
99 assertFalse("Checkbox ST-DemoCheckboxControlExample2-Input1_control_4 is checked", isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_4"));
100
101
102 checkById("ST-DemoCheckboxControlExample2-Input1_control_1");
103
104
105 assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_0"));
106 assertTrue(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_1"));
107 assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_2"));
108 assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_3"));
109 assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_4"));
110 }
111
112
113 @Test
114 public void testCheckboxControlOptionsFinderBookmark() throws Exception {
115 testCheckboxControlOptionsFinder();
116 passed();
117 }
118
119 @Test
120 public void testCheckboxControlOptionsFinderNav() throws Exception {
121 navigateToLibraryDemo("Controls", "Checkbox");
122 testCheckboxControlOptionsFinder();
123 passed();
124 }
125
126 protected void testCheckboxControlKeyValuePair() throws Exception {
127 navigateToExample("Demo-CheckboxControl-Example3");
128
129 waitForElementPresentById("ST-DemoCheckboxControlExample3-Input1_control_0");
130 waitForElementPresentById("ST-DemoCheckboxControlExample3-Input1_control_1");
131 assertTextPresent("CheckboxControl with key value set as options");
132 assertTextPresent("CheckboxGroupControl");
133 assertLabelFor("ST-DemoCheckboxControlExample3-Input1_control_0", "Check 1");
134 assertLabelFor("ST-DemoCheckboxControlExample3-Input1_control_1", "Check 2");
135
136
137 WebElement we = driver.findElement(By.id("ST-DemoCheckboxControlExample3-Input1_fieldset"));
138 assertTrue(we.getAttribute("class").matches(".*\\buif-verticalCheckboxesFieldset\\b.*"));
139
140
141 assertTrue(isVisibleById("ST-DemoCheckboxControlExample3-Input1_control_0"));
142 assertTrue(isVisibleById("ST-DemoCheckboxControlExample3-Input1_control_1"));
143 assertTrue(isEnabledById("ST-DemoCheckboxControlExample3-Input1_control_0"));
144 assertTrue(isEnabledById("ST-DemoCheckboxControlExample3-Input1_control_1"));
145 assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_0"));
146 assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_1"));
147
148
149 checkById("ST-DemoCheckboxControlExample3-Input1_control_1");
150
151
152 assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_0"));
153 assertTrue(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_1"));
154 }
155
156
157 @Test
158 public void testCheckboxControlKeyValuePairBookmark() throws Exception {
159 testCheckboxControlOptionsFinder();
160 passed();
161 }
162
163 @Test
164 public void testCheckboxControlKeyValuePairNav() throws Exception {
165 navigateToLibraryDemo("Controls", "Checkbox");
166 testCheckboxControlKeyValuePair();
167 passed();
168 }
169
170 protected void testCheckboxControlDisabled() throws Exception {
171 navigateToExample("Demo-CheckboxControl-Example4");
172
173 waitForElementPresentById("ST-DemoCheckboxControlExample4-Input1_control");
174 assertTextPresent("CheckboxControl with disabled set to true");
175 assertLabelFor("ST-DemoCheckboxControlExample4-Input1_control", "Add me to your mailing list");
176
177
178 assertTrue(isVisibleById("ST-DemoCheckboxControlExample4-Input1_control"));
179 assertFalse(isCheckedById("ST-DemoCheckboxControlExample4-Input1_control"));
180 assertFalse(isEnabledById("ST-DemoCheckboxControlExample4-Input1_control"));
181 }
182
183
184 @Test
185 public void testCheckboxControlDisabledBookmark() throws Exception {
186 testCheckboxControlDisabled();
187 passed();
188 }
189
190 @Test
191 public void testCheckboxControlDisabledNav() throws Exception {
192 navigateToLibraryDemo("Controls", "Checkbox");
193 testCheckboxControlDisabled();
194 passed();
195 }
196
197 protected void testCheckboxControlDelimiter() throws Exception {
198 navigateToExample("Demo-CheckboxControl-Example6");
199
200 waitForElementPresentById("ST-DemoCheckboxControlExample6-Input1_control_0");
201 waitForElementPresentById("ST-DemoCheckboxControlExample6-Input1_control_1");
202 assertTextPresent("HorizontalCheckboxesControl with delimiter set to ;");
203 assertLabelFor("ST-DemoCheckboxControlExample6-Input1_control_0", "Check 1");
204 assertLabelFor("ST-DemoCheckboxControlExample6-Input1_control_1", "Check 2");
205
206
207 WebElement we = driver.findElement(By.id("ST-DemoCheckboxControlExample6-Input1_fieldset"));
208 assertTrue(we.getAttribute("class").matches(".*\\buif-horizontalCheckboxesFieldset\\b.*"));
209
210
211 assertTrue("Checkbox 1 not visible", isVisibleById("ST-DemoCheckboxControlExample6-Input1_control_0"));
212 assertTrue("Checkbox 2 not visible", isVisibleById("ST-DemoCheckboxControlExample6-Input1_control_1"));
213 assertTrue("Checkbox 1 not enabled", isEnabledById("ST-DemoCheckboxControlExample6-Input1_control_0"));
214 assertTrue("Checkbox 2 not enabled", isEnabledById("ST-DemoCheckboxControlExample6-Input1_control_1"));
215 assertFalse("Checkbox 1 is checked", isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_0"));
216 assertFalse("Checkbox 2 is checked", isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_1"));
217
218
219 checkById("ST-DemoCheckboxControlExample6-Input1_control_1");
220
221
222 assertFalse("Checkbox 1 is checked", isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_0"));
223 assertTrue("Checkbox 2 not checked", isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_1"));
224 }
225
226 @Test
227 public void testCheckboxControlDelimiterBookmark() throws Exception {
228 testCheckboxControlDelimiter();
229 passed();
230 }
231
232 @Test
233 public void testCheckboxControlDelimiterNav() throws Exception {
234 navigateToLibraryDemo("Controls", "Checkbox");
235 testCheckboxControlDelimiter();
236 passed();
237 }
238
239 protected void testCheckboxControlEvaluateDisabledOnKeyUp() throws Exception {
240 navigateToExample("Demo-CheckboxControl-Example7");
241
242 waitForElementPresentById("ST-DemoCheckboxControlExample7-Input1_control");
243 waitForElementPresentById("ST-DemoCheckboxControlExample7-Input2_control");
244 assertTextPresent("Evaluate the disabled condition on each key up event");
245
246
247 assertTrue(isVisibleById("ST-DemoCheckboxControlExample7-Input2_control"));
248 assertFalse(isCheckedById("ST-DemoCheckboxControlExample7-Input2_control"));
249 assertFalse(isEnabledById("ST-DemoCheckboxControlExample7-Input2_control"));
250
251
252 driver.findElement(By.id("ST-DemoCheckboxControlExample7-Input1_control")).sendKeys(Keys.SPACE);
253
254
255 assertTrue(isVisibleById("ST-DemoCheckboxControlExample7-Input2_control"));
256 assertFalse(isCheckedById("ST-DemoCheckboxControlExample7-Input2_control"));
257 assertTrue(isEnabledById("ST-DemoCheckboxControlExample7-Input2_control"));
258 }
259
260
261 @Test
262 public void testCheckboxControlDisabledOnKeyEventBookmark() throws Exception {
263 testCheckboxControlEvaluateDisabledOnKeyUp();
264 passed();
265 }
266
267 @Test
268 public void testCheckboxControlDisabledOnKeyEventNav() throws Exception {
269 navigateToLibraryDemo("Controls", "Checkbox");
270 testCheckboxControlEvaluateDisabledOnKeyUp();
271 passed();
272 }
273
274 protected void testCheckboxControlEnableWhenChanged() throws Exception {
275 navigateToExample("Demo-CheckboxControl-Example8");
276
277 waitForElementPresentById("ST-DemoCheckboxControlExample8-Input1_control");
278 waitForElementPresentById("ST-DemoCheckboxControlExample8-Input2_control");
279 assertTextPresent("Specifies the property names of fields that when changed, will enable this component");
280
281
282 assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
283 assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
284 assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
285
286
287 driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys(Keys.BACK_SPACE);
288 driver.findElement(By.id("Demo-CheckboxControl-Example8")).sendKeys(Keys.ARROW_DOWN);
289
290
291 assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
292 assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
293 assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
294
295
296 driver.findElement(By.id("ST-DemoCheckboxControlExample8-Input1_control")).sendKeys("Hello");
297 driver.findElement(By.id("Demo-CheckboxControl-Example8")).sendKeys(Keys.ARROW_DOWN);
298
299
300 assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
301 assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
302 assertTrue(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
303 }
304
305 @Test
306 public void testCheckboxControlEnableWhenChangedBookmark() throws Exception {
307 testCheckboxControlEnableWhenChanged();
308 passed();
309 }
310
311 @Test
312 public void testCheckboxControlEnableWhenChangedNav() throws Exception {
313 navigateToLibraryDemo("Controls", "Checkbox");
314 testCheckboxControlEnableWhenChanged();
315 passed();
316 }
317
318 protected void testCheckboxControlDisableWhenChanged() throws Exception {
319 navigateToExample("Demo-CheckboxControl-Example9");
320
321 waitForElementPresentById("ST-DemoCheckboxControlExample9-Input1_control");
322 waitForElementPresentById("ST-DemoCheckboxControlExample9-Input2_control");
323 assertTextPresent("Specifies the property names of fields that when changed, will disable this component");
324
325
326 assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
327 assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
328 assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
329
330
331 driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys(Keys.BACK_SPACE);
332 driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);
333
334
335 assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
336 assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
337 assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
338
339
340 driver.findElement(By.id("ST-DemoCheckboxControlExample9-Input1_control")).sendKeys("Hello");
341 driver.findElement(By.id("Demo-CheckboxControl-Example9")).sendKeys(Keys.ARROW_DOWN);
342
343
344 assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
345 assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
346 assertFalse(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
347 }
348
349 @Test
350 public void testCheckboxControlDisableWhenChangedBookmark() throws Exception {
351 testCheckboxControlDisableWhenChanged();
352 passed();
353 }
354
355 @Test
356 public void testCheckboxControlDisableWhenChangedNav() throws Exception {
357 navigateToLibraryDemo("Controls", "Checkbox");
358 testCheckboxControlDisableWhenChanged();
359 passed();
360 }
361 }