001 /*
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.krad.demo.uif.library;
017
018 import com.thoughtworks.selenium.SeleneseTestBase;
019 import org.junit.Test;
020 import org.openqa.selenium.By;
021 import org.openqa.selenium.Keys;
022 import org.openqa.selenium.WebElement;
023
024 /**
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 */
027 public class DemoLibraryControlCheckboxDefaultSmokeTest extends DemoLibraryBase {
028
029 /**
030 * /kr-krad/kradsampleapp?viewId=ComponentLibraryHome
031 */
032 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CheckboxControl-View";
033
034 @Override
035 public String getBookmarkUrl() {
036 return BOOKMARK_URL;
037 }
038
039 @Override
040 protected void navigate() throws Exception {
041 navigateToExample("Demo-CheckboxControl-Example1");
042 }
043
044 protected void testCheckboxControlDefault() throws Exception {
045 waitForElementPresentById("ST-DemoCheckboxControlExample1-Input1_control");
046 assertTextPresent("Default Checkbox Control");
047 assertLabelFor("ST-DemoCheckboxControlExample1-Input1_control", "Add me to your mailing list");
048 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample1-Input1_control"));
049 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample1-Input1_control"));
050 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample1-Input1_control"));
051 checkById("ST-DemoCheckboxControlExample1-Input1_control");
052 SeleneseTestBase.assertTrue(isCheckedById("ST-DemoCheckboxControlExample1-Input1_control"));
053 }
054
055
056 @Test
057 public void testCheckboxControlDefaultBookmark() throws Exception {
058 testCheckboxControlDefault();
059 passed();
060 }
061
062 @Test
063 public void testCheckboxControlDefaultNav() throws Exception {
064 navigateToLibraryDemo("Controls", "Checkbox");
065 testCheckboxControlDefault();
066 passed();
067 }
068
069 protected void testCheckboxControlOptionsFinder() throws Exception {
070 navigateToExample("Demo-CheckboxControl-Example2");
071
072 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_0");
073 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_1");
074 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_2");
075 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_3");
076 waitForElementPresentById("ST-DemoCheckboxControlExample2-Input1_control_4");
077 assertTextPresent("CheckboxControl with optionsFinder set");
078 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_0", "Option 1");
079 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_1", "Option 2");
080 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_2", "Option 3");
081 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_3", "Option 4");
082 assertLabelFor("ST-DemoCheckboxControlExample2-Input1_control_4", "Option 5");
083
084 // check that checkbox controls are enabled and visible but not selected
085 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_0"));
086 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_1"));
087 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_2"));
088 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_3"));
089 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample2-Input1_control_4"));
090 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_0"));
091 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_1"));
092 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_2"));
093 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_3"));
094 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample2-Input1_control_4"));
095 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_0"));
096 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_1"));
097 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_2"));
098 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_3"));
099 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_4"));
100
101 // set check mark on second checkbox control
102 checkById("ST-DemoCheckboxControlExample2-Input1_control_1");
103
104 // check that only second checkbox controls is selected
105 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_0"));
106 SeleneseTestBase.assertTrue(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_1"));
107 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_2"));
108 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample2-Input1_control_3"));
109 SeleneseTestBase.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 // check that fieldset is vertical
137 WebElement we = driver.findElement(By.id("ST-DemoCheckboxControlExample3-Input1_fieldset"));
138 SeleneseTestBase.assertTrue(we.getAttribute("class").matches(".*\\buif-verticalCheckboxesFieldset\\b.*"));
139
140 // check that checkbox controls are enabled and visible but not selected
141 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample3-Input1_control_0"));
142 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample3-Input1_control_1"));
143 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample3-Input1_control_0"));
144 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample3-Input1_control_1"));
145 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_0"));
146 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_1"));
147
148 // set check mark on second checkbox control
149 checkById("ST-DemoCheckboxControlExample3-Input1_control_1");
150
151 // check that only second checkbox controls is selected
152 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample3-Input1_control_0"));
153 SeleneseTestBase.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 // check that checkbox controls is visible, not selected and disabled
178 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample4-Input1_control"));
179 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample4-Input1_control"));
180 SeleneseTestBase.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 // check that fieldset is horizonal
207 WebElement we = driver.findElement(By.id("ST-DemoCheckboxControlExample6-Input1_fieldset"));
208 SeleneseTestBase.assertTrue(we.getAttribute("class").matches(".*\\buif-horizontalCheckboxesFieldset\\b.*"));
209
210 // check that checkbox controls are enabled and visible but not selected
211 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample6-Input1_control_0"));
212 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample6-Input1_control_1"));
213 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample6-Input1_control_0"));
214 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample6-Input1_control_1"));
215 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_0"));
216 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_1"));
217
218 // set check mark on second checkbox control
219 checkById("ST-DemoCheckboxControlExample6-Input1_control_1");
220
221 // check that only second checkbox controls is selected
222 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample6-Input1_control_0"));
223 SeleneseTestBase.assertTrue(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 testCheckboxControlDisabledOnKeyEvent() throws Exception {
240 navigateToExample("Demo-CheckboxControl-Example7");
241
242 waitForElementPresentById("ST-DemoCheckboxControlExample7-Input1_control");
243 waitForElementPresentById("ST-DemoCheckboxControlExample7-Input2_control");
244 assertTextPresent("Evaluate the disable condition on controls which disable it on each key up event");
245
246 // check that checkbox controls is visible, not selected and enabled
247 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample7-Input2_control"));
248 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample7-Input2_control"));
249 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample7-Input2_control"));
250
251 // backspace input1
252 driver.findElement(By.id("ST-DemoCheckboxControlExample7-Input1_control")).sendKeys(Keys.BACK_SPACE);
253
254 // check that checkbox controls is visible, not selected and disabled
255 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample7-Input2_control"));
256 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample7-Input2_control"));
257 SeleneseTestBase.assertFalse(isEnabledById("ST-DemoCheckboxControlExample7-Input2_control"));
258 }
259
260
261 @Test
262 public void testCheckboxControlDisabledOnKeyEventBookmark() throws Exception {
263 testCheckboxControlDisabledOnKeyEvent();
264 passed();
265 }
266
267 @Test
268 public void testCheckboxControlDisabledOnKeyEventNav() throws Exception {
269 navigateToLibraryDemo("Controls", "Checkbox");
270 testCheckboxControlDisabledOnKeyEvent();
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 // check that checkbox controls is visible, not selected and disabled
282 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
283 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
284 SeleneseTestBase.assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
285
286 // backspace input1 and remove focus from input1 (by doing an arrow down on the div)
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 // check that checkbox controls is visible, not selected and disabled
291 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
292 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
293 SeleneseTestBase.assertFalse(isEnabledById("ST-DemoCheckboxControlExample8-Input2_control"));
294
295 // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the div)
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 // check that checkbox controls is visible, not selected and enabled
300 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample8-Input2_control"));
301 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample8-Input2_control"));
302 SeleneseTestBase.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 // check that checkbox controls is visible, not selected and enabled
326 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
327 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
328 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
329
330 // backspace input1 and remove focus from input1 (by doing an arrow down on the checkbox)
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 // check that checkbox controls is visible, not selected and enabled
335 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
336 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
337 SeleneseTestBase.assertTrue(isEnabledById("ST-DemoCheckboxControlExample9-Input2_control"));
338
339 // type "Hello" in input1 and remove focus from input1 (by doing an arrow down on the checkbox)
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 // check that checkbox controls is visible, not selected and disabled
344 SeleneseTestBase.assertTrue(isVisibleById("ST-DemoCheckboxControlExample9-Input2_control"));
345 SeleneseTestBase.assertFalse(isCheckedById("ST-DemoCheckboxControlExample9-Input2_control"));
346 SeleneseTestBase.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 }