1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.configview;
17
18 import com.thoughtworks.selenium.SeleneseTestBase;
19 import edu.samplu.common.SmokeTestBase;
20 import org.junit.Test;
21 import org.openqa.selenium.By;
22
23
24
25
26 public class CollectionsSmokeTest extends SmokeTestBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=ConfigurationTestView-Collections&methodToCall=start";
32
33
34
35
36 public static final String TEXT_COLLECTIONS_CONFIGURATION_TEST_VIEW_XPATH =
37 "(//a[contains(text(),'Collections Configuration Test View')])[2]";
38
39
40
41
42 public static final String KUALI_COLLECTION_WINDOW_TITLE = "Kuali :: Collection Test View";
43
44 @Override
45 protected String getBookmarkUrl() {
46 return BOOKMARK_URL;
47 }
48
49 protected void navigate() throws Exception {
50 waitAndClickKRAD();
51 waitAndClickByXpath(TEXT_COLLECTIONS_CONFIGURATION_TEST_VIEW_XPATH);
52 switchToWindow(KUALI_COLLECTION_WINDOW_TITLE);
53 }
54
55 protected void testCollections() throws Exception {
56 testActionColumnPlacement();
57 testAddViaLightbox();
58 testColumnSequence();
59 testSequencerow();
60 passed();
61 }
62
63 @Test
64 public void testCollectionsBookmark() throws Exception {
65 testCollections();
66 }
67
68 @Test
69 public void testCollectionsNav() throws Exception {
70 testCollections();
71 }
72
73 @Test
74 public void testAddDeleteBookmark() throws Exception {
75 testAddRowOfText();
76 testAddBlankLine();
77 passed();
78 }
79
80 @Test
81 public void testAddDeleteNav() throws Exception {
82 testAddRowOfText();
83 testAddBlankLine();
84 passed();
85 }
86
87 @Test
88 public void testSumBookmark() throws Exception {
89 testSum();
90 passed();
91 }
92
93 @Test
94 public void testSumNav() throws Exception {
95 testSum();
96 passed();
97 }
98
99 protected void testAddRowOfText() throws Exception {
100 assertTableLayout();
101 waitAndTypeByName("newCollectionLines['list1'].field1", "asdf1");
102 waitAndTypeByName("newCollectionLines['list1'].field2", "asdf2");
103 waitAndTypeByName("newCollectionLines['list1'].field3", "asdf3");
104 waitAndTypeByName("newCollectionLines['list1'].field4", "asdf4");
105 waitAndClickByXpath("//button[contains(.,'add')]"); // the first button is the one we want
106
107 for (int second = 0;; second++) {
108 if (second >= waitSeconds)
109 failableFail(TIMEOUT_MESSAGE);
110 try {
111 if (getAttributeByName("newCollectionLines['list1'].field1", "value").equals(""))
112 break;
113 } catch (Exception e) {}
114 Thread.sleep(1000);
115 }
116
117 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field1", "value"));
118 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field2", "value"));
119 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field3", "value"));
120 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field4", "value"));
121 SeleneseTestBase.assertEquals("asdf1", getAttributeByName("list1[0].field1", "value"));
122 SeleneseTestBase.assertEquals("asdf2", getAttributeByName("list1[0].field2", "value"));
123 SeleneseTestBase.assertEquals("asdf3", getAttributeByName("list1[0].field3", "value"));
124 SeleneseTestBase.assertEquals("asdf4", getAttributeByName("list1[0].field4", "value"));
125 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Collections-Base-TableLayout_disclosureContent']/div/table/tbody/tr[2]/td[6]/div/fieldset/div/div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button"));
126 }
127
128
129
130 protected void testAddBlankLine() throws Exception {
131 waitAndClickByLinkText("Add Blank Line");
132 waitAndClickById("Collections-AddBlankLine-TableTop_del_line0");
133 Thread.sleep(3000);
134 waitAndClickByXpath("//button[contains(.,'Add Line')]");
135 Thread.sleep(3000);
136 assertElementPresentByName("list1[0].field1");
137 assertTableLayout();
138 SeleneseTestBase.assertEquals("", getAttributeByName("list1[0].field1", "value"));
139 SeleneseTestBase.assertEquals("", getAttributeByName("list1[0].field2", "value"));
140 SeleneseTestBase.assertEquals("", getAttributeByName("list1[0].field3", "value"));
141 SeleneseTestBase.assertEquals("", getAttributeByName("list1[0].field4", "value"));
142 }
143
144 private void testSum() throws InterruptedException {
145 SeleneseTestBase.assertEquals("5", getAttributeByName("list1[0].field1", "value"));
146 SeleneseTestBase.assertEquals("6", getAttributeByName("list1[0].field2", "value"));
147 SeleneseTestBase.assertEquals("7", getAttributeByName("list1[0].field3", "value"));
148 SeleneseTestBase.assertEquals("8", getAttributeByName("list1[0].field4", "value"));
149 SeleneseTestBase.assertEquals("Total: 419", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
150 waitAndTypeByName("list1[0].field1", "1");
151 waitAndTypeByName("list1[0].field2", "1");
152 waitAndTypeByName("list1[0].field3", "1");
153 waitAndTypeByName("list1[0].field4", "1");
154 SeleneseTestBase.assertEquals("Total: 465", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
155 }
156
157
158
159
160 protected void testActionColumnPlacement() throws Exception {
161
162
163
164 waitAndClickByLinkText("Column Sequence");
165 Thread.sleep(2000);
166
167
168
169
170 for (int second = 0;; second++) {
171 if (second >= waitSeconds)
172 failableFail(TIMEOUT_MESSAGE);
173 try {
174 if (isElementPresentByXpath("//tr[2]/td[6]/div/fieldset/div/div[2]/button"))
175 break;
176 } catch (Exception e) {}
177 Thread.sleep(1000);
178 }
179 SeleneseTestBase.assertTrue(isElementPresentByXpath("//tr[2]/td[6]/div/fieldset/div/div[2]/button"));
180
181
182
183 for (int second = 0;; second++) {
184 if (second >= waitSeconds)
185 failableFail(TIMEOUT_MESSAGE);
186 try {
187 if (isElementPresentByXpath("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button"))
188 break;
189 } catch (Exception e) {}
190 Thread.sleep(1000);
191 }
192 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button"));
193
194
195
196 for (int second = 0;; second++) {
197 if (second >= waitSeconds)
198 failableFail(TIMEOUT_MESSAGE);
199 try {
200 if (isElementPresentByXpath("//tr[2]/td[3]/div/fieldset/div/div[2]/button"))
201 break;
202 } catch (Exception e) {}
203 Thread.sleep(1000);
204 }
205 SeleneseTestBase.assertTrue(isElementPresentByXpath("//tr[2]/td[3]/div/fieldset/div/div[2]/button"));
206 }
207
208 protected void testAddViaLightbox() throws Exception {
209 waitAndClickByLinkText("Add Via Lightbox");
210 SeleneseTestBase.assertEquals("Total: 419", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
211 waitAndClickByXpath("//button[contains(.,'Add Line')]");
212 Thread.sleep(3000);
213 waitAndTypeByXpath("//form/div/table/tbody/tr/td/div/input", "1");
214 waitAndTypeByXpath("//form/div/table/tbody/tr[2]/td/div/input", "1");
215 waitAndTypeByXpath("//form/div/table/tbody/tr[3]/td/div/input", "1");
216 waitAndTypeByXpath("//form/div/table/tbody/tr[4]/td/div/input", "1");
217 waitAndClickByXpath("//button[@id='Collections-AddViaLightbox-TableTop_add']");
218 Thread.sleep(3000);
219 SeleneseTestBase.assertEquals("Total: 420", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
220 }
221
222 protected void testColumnSequence() throws Exception {
223 waitAndClickByLinkText("Column Sequence");
224 Thread.sleep(3000);
225 waitAndTypeByName("newCollectionLines['list1'].field1", "1");
226 waitAndTypeByName("newCollectionLines['list1'].field2", "1");
227 waitAndTypeByName("newCollectionLines['list1'].field3", "1");
228 waitAndTypeByName("newCollectionLines['list1'].field4", "1");
229 waitAndClick(By.id("Collections-ColumnSequence-TableDefault_add"));
230 Thread.sleep(3000);
231
232
233 testIfRowHasBeenAdded();
234
235
236 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Collections-ColumnSequence-TableDefault_disclosureContent']/div[@class='dataTables_wrapper']/table/tbody/tr[2]/td[6]/div/fieldset/div/div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button"));
237 }
238
239 protected void testSequencerow() throws Exception {
240 waitAndClickByLinkText("Save Row");
241 Thread.sleep(3000);
242 waitAndTypeByName("newCollectionLines['list1'].field1", "1");
243 waitAndTypeByName("newCollectionLines['list1'].field2", "1");
244 waitAndTypeByName("newCollectionLines['list1'].field3", "1");
245 waitAndTypeByName("newCollectionLines['list1'].field4", "1");
246 waitAndClickByXpath("//button[contains(.,'add')]");
247 Thread.sleep(3000);
248
249
250 testIfRowHasBeenAdded();
251
252
253 SeleneseTestBase.assertTrue(isElementPresentByXpath("//div[@id='Collections-SaveRow-Table_disclosureContent']/div[@class='dataTables_wrapper']/table/tbody/tr[2]/td[6]/div/fieldset/div/div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button"));
254
255 }
256
257 protected void testIfRowHasBeenAdded() throws Exception {
258
259 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field1", "value"));
260 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field2", "value"));
261 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field3", "value"));
262 SeleneseTestBase.assertEquals("", getAttributeByName("newCollectionLines['list1'].field4", "value"));
263 SeleneseTestBase.assertEquals("1", getAttributeByName("list1[0].field1", "value"));
264 SeleneseTestBase.assertEquals("1", getAttributeByName("list1[0].field2", "value"));
265 SeleneseTestBase.assertEquals("1", getAttributeByName("list1[0].field3", "value"));
266 SeleneseTestBase.assertEquals("1", getAttributeByName("list1[0].field4", "value"));
267 }
268 }