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