1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.collections;
17
18 import org.junit.Test;
19
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21 import org.openqa.selenium.By;
22
23
24
25
26 public class LibraryCollectionFeaturesAddLineAft extends WebDriverLegacyITBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionAddLineView";
32
33 @Override
34 protected String getBookmarkUrl() {
35 return BOOKMARK_URL;
36 }
37
38 @Override
39 protected void navigate() throws Exception {
40 waitAndClickLibraryLink();
41 waitAndClickByLinkText("Collection Features");
42 waitAndClickByLinkText("Add Line");
43 }
44
45 protected void testCollectionFeaturesAddLine() throws Exception {
46 selectByName("exampleShown", "Collection Default Add Line");
47
48
49 waitAndTypeByName("newCollectionLines['collection1'].field1", "12");
50 waitAndTypeByName("newCollectionLines['collection1'].field2", "5");
51 jGrowl("Click Add button.");
52 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example1']//button[contains(text(), 'Add')]");
53
54
55 waitForElementPresent("input[name = 'collection1[0].field1'][value = '12']");
56 waitForElementPresent("input[name = 'collection1[0].field2'][value = '5']");
57 }
58
59 protected void testCollectionFeaturesAddLineWithDuplicatePropertyName() throws Exception {
60 selectByName("exampleShown", "Collection Add Line with duplicateLinePropertyNames");
61
62
63 waitAndTypeByName("newCollectionLines['collection1_2'].field1", "13");
64 waitAndTypeByName("newCollectionLines['collection1_2'].field2", "14");
65 jGrowl("Click Add button.");
66 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example2']//button[contains(text(), 'Add')]");
67
68
69 waitForTextPresent("Duplicate Default Add Line with duplicateLinePropertyNames property configured");
70 }
71
72 protected void testCollectionFeaturesAddLineWithDialog() throws Exception {
73 selectByName("exampleShown", "Collection Add Line with Dialog");
74
75
76 jGrowl("Click Add Line button.");
77 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example3']//button[contains(text(), 'Add Line')]");
78
79
80 waitForElementPresentByName("newCollectionLines['collection1_3'].field1");
81 jGrowl("Click Add button.");
82 waitAndClickByXpath("//div[@id = 'Uif-Dialogs']//button[contains(text(), 'Add')]");
83
84
85 waitIsVisible("div[data-label = 'Field 1'] li[class = 'uif-errorMessageItem-field']");
86
87
88 waitAndTypeByName("newCollectionLines['collection1_3'].field1", "42");
89 waitAndTypeByName("newCollectionLines['collection1_3'].field2", "55");
90 jGrowl("Click Add button.");
91 waitAndClickByXpath("//div[@id = 'Uif-Dialogs']//button[contains(text(), 'Add')]");
92
93
94 waitForElementPresent("input[name = 'collection1_3[0].field1'][value = '42']");
95 waitForElementPresent("input[name = 'collection1_3[0].field2'][value = '55']");
96 }
97
98 protected void testCollectionFeaturesAddBlankLine() throws Exception {
99 selectByName("exampleShown", "Collection Add Blank Line");
100
101
102 jGrowl("Click Add Line button.");
103 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example4']//button[contains(text(), 'Add Line')]");
104
105
106 waitForElementPresent("input[name = 'collection1_7[0].field1'][value = '']");
107 waitForElementPresent("input[name = 'collection1_7[0].field2'][value = '']");
108 }
109
110 protected void testCollectionFeaturesAddLineWithCustomActions() throws Exception {
111 selectByName("exampleShown", "Collection Add Line with Custom Actions");
112
113
114 waitAndTypeByName("newCollectionLines['collection1_8'].field1", "999");
115 waitAndTypeByName("newCollectionLines['collection1_8'].field2", "999");
116 jGrowl("Click Add button.");
117 waitAndClickByXpath("//section[@data-parent='Demo-CollectionAddLine-Example5']//button[contains(text(),'Add')]");
118
119
120 waitForElementPresent("input[name = 'collection1_8[0].field1'][value = '999']");
121 waitForElementPresent("input[name = 'collection1_8[0].field2'][value = '999']");
122
123
124 jGrowl("Click Trash button.");
125 waitAndClick("#Demo-CollectionAddLine-Example5 button.icon-trash");
126
127
128 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_8[0].field1'][value = '999']"));
129 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_8[0].field2'][value = '999']"));
130 waitForTextPresent("You have deleted an item from Project Income.");
131 }
132
133 protected void testCollectionFeaturesAddLineWithDialogAndCustomActions() throws Exception {
134 selectByName("exampleShown", "Collection Add Line with Dialog and Custom Actions");
135
136
137 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example6']//button/text()[contains(., 'Add Income')]/..");
138 waitAndTypeByName("newCollectionLines['collection1_9'].field1", "999");
139 waitAndTypeByName("newCollectionLines['collection1_9'].field2", "999");
140 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example6-AddLineDialog']//button[contains(text(),'Cancel')]");
141
142
143 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_9[0].field1'][value = '999']"));
144 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_9[0].field2'][value = '999']"));
145
146
147 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example6']//button/text()[contains(., 'Add Income')]/..");
148 waitForElementPresentByName("newCollectionLines['collection1_9'].field1");
149 clearTextByName("newCollectionLines['collection1_9'].field1");
150 waitAndTypeByName("newCollectionLines['collection1_9'].field1", "999");
151 waitForElementPresentByName("newCollectionLines['collection1_9'].field2");
152 clearTextByName("newCollectionLines['collection1_9'].field2");
153 waitAndTypeByName("newCollectionLines['collection1_9'].field2", "999");
154 jGrowl("Click Add Income button.");
155 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example6-AddLineDialog']//button[contains(text(), 'Add Income')]");
156
157
158 waitForElementPresent("input[name = 'collection1_9[0].field1'][value = '999']");
159 waitForElementPresent("input[name = 'collection1_9[0].field2'][value = '999']");
160
161
162 jGrowl("Click Trash button.");
163 waitAndClick("#Demo-CollectionAddLine-Example6 button.icon-trash");
164
165
166 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_9[0].field1'][value = '999']"));
167 waitForElementNotPresent(By.cssSelector("input[name = 'collection1_9[0].field2'][value = '999']"));
168 waitForTextPresent("You have deleted an item from Project Income.");
169 }
170
171 protected void testCollectionFeaturesAddRefreshingDialog() throws Exception {
172 selectByName("exampleShown", "Collection Add Line with Refreshing Dialog");
173
174
175 jGrowl("Click Add Income button.");
176 waitAndClickByXpath("//section[@id = 'Demo-CollectionAddLine-Example7']//button/text()[contains(., 'Add Income')]/..");
177
178
179 waitForElementNotPresent(By.xpath("//section[@id = 'Demo-CollectionAddLine-Example7-AddLineDialog']//button[contains(text(), 'Add Income')]"));
180
181
182 waitAndTypeByName("newCollectionLines['collection1_10'].field1", "77");
183 waitAndTypeByName("newCollectionLines['collection1_10'].field2", "");
184 waitForProgressLoading();
185
186
187 waitForElementPresent(By.xpath("//section[@id = 'Demo-CollectionAddLine-Example7-AddLineDialog']//button[contains(text(), 'Add Income')]"));
188 }
189
190 @Test
191 public void testCollectionFeaturesAddLineBookmark() throws Exception {
192 testCollectionFeaturesAddLine();
193 testCollectionFeaturesAddLineWithDuplicatePropertyName();
194 testCollectionFeaturesAddLineWithDialog();
195 testCollectionFeaturesAddBlankLine();
196 testCollectionFeaturesAddLineWithCustomActions();
197 testCollectionFeaturesAddLineWithDialogAndCustomActions();
198 testCollectionFeaturesAddRefreshingDialog();
199 passed();
200 }
201
202 @Test
203 public void testCollectionFeaturesAddLineNav() throws Exception {
204 testCollectionFeaturesAddLine();
205 testCollectionFeaturesAddLineWithDuplicatePropertyName();
206 testCollectionFeaturesAddLineWithDialog();
207 testCollectionFeaturesAddBlankLine();
208 testCollectionFeaturesAddLineWithCustomActions();
209 testCollectionFeaturesAddLineWithDialogAndCustomActions();
210 testCollectionFeaturesAddRefreshingDialog();
211 passed();
212 }
213
214 }