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
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21
22
23
24
25 public class LibraryControlCheckboxGroupAft extends WebDriverLegacyITBase {
26
27
28
29
30 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CheckboxGroupControlView&methodToCall=start";
31
32 @Override
33 protected String getBookmarkUrl() {
34 return BOOKMARK_URL;
35 }
36
37 @Override
38 protected void navigate() throws Exception {
39 waitAndClickLibraryLink();
40 waitAndClickByLinkText("Controls");
41 waitAndClickByLinkText("Checkbox Group");
42 }
43
44 protected void testLibraryControlCheckboxGroupOptionsFinder() throws Exception {
45 waitAndClickByLinkText("optionsFinder");
46 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField1' and @value='1']");
47 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField1' and @value='5']");
48 }
49
50 protected void testLibraryControlCheckboxGroupKeyValuePairs() throws Exception {
51 waitAndClickByLinkText("Key Value Pairs");
52 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField2' and @value='1']");
53 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField2' and @value='3']");
54 }
55
56 protected void testLibraryControlCheckboxGroupHorizontal() throws Exception {
57 waitAndClickByLinkText("Horizontal");
58 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField3' and @value='1']");
59 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField3' and @value='2']");
60 }
61
62 protected void testLibraryControlCheckboxGroupDelimiter() throws Exception {
63 waitAndClickByLinkText("Delimiter");
64 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField4' and @value='1']");
65 assertTextPresent("\n|");
66 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField4' and @value='2']");
67 }
68
69 protected void testLibraryControlCheckboxGroupDirtyValidation() throws Exception {
70
71
72 waitAndClickByLinkText("optionsFinder");
73 checkByName("checkboxesField1");
74 waitAndClickByLinkText("File");
75 Thread.sleep(3000);
76 if(isAlertPresent()) {
77 alertAccept();
78 } else {
79 fail("An alert should have popped up to warn the user about unsaved data.");
80 }
81
82 waitForTextPresent("File Control");
83 waitAndClickByLinkText("Checkbox Group");
84 waitAndClickByLinkText("optionsFinder");
85 waitForElementPresentByXpath("//input[@type='checkbox' and @name='checkboxesField1' and @value='1']");
86 waitAndClickByLinkText("File");
87 waitForTextPresent("File Control");
88 if(isAlertPresent()) {
89 fail("No data was changed so there should be no alert.");
90 }
91 }
92
93 protected boolean isAlertPresent() {
94 try {
95 driver.switchTo().alert();
96 return true;
97 }
98 catch (Exception Ex) {
99 return false;
100 }
101 }
102
103 @Test
104 public void testControlCheckboxGroupBookmark() throws Exception {
105 testLibraryControlCheckboxGroupOptionsFinder();
106 testLibraryControlCheckboxGroupKeyValuePairs();
107 testLibraryControlCheckboxGroupHorizontal();
108 testLibraryControlCheckboxGroupDelimiter();
109 testLibraryControlCheckboxGroupDirtyValidation();
110 passed();
111 }
112
113 @Test
114 public void testControlCheckboxGroupNav() throws Exception {
115 testLibraryControlCheckboxGroupOptionsFinder();
116 testLibraryControlCheckboxGroupKeyValuePairs();
117 testLibraryControlCheckboxGroupHorizontal();
118 testLibraryControlCheckboxGroupDelimiter();
119 testLibraryControlCheckboxGroupDirtyValidation();
120 passed();
121 }
122 }