1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.configview;
18
19 import edu.samplu.common.WebDriverLegacyITBase;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.openqa.selenium.By;
23
24
25
26
27
28
29 public class CollectionsLegacyIT extends WebDriverLegacyITBase {
30
31
32 @Override
33 public String getTestUrl() {
34 return "/kr-krad/uicomponents?viewId=ConfigurationTestView-Collections&methodToCall=start";
35 }
36
37
38
39
40 @Test
41 public void testDefaultTestsTableLayout() throws Exception{
42
43 assertTableLayout();
44 waitAndTypeByName("newCollectionLines['list1'].field1", "asdf1");
45 waitAndTypeByName("newCollectionLines['list1'].field2", "asdf2");
46 waitAndTypeByName("newCollectionLines['list1'].field3", "asdf3");
47 waitAndTypeByName("newCollectionLines['list1'].field4", "asdf4");
48 waitAndClickByXpath("//button[contains(.,'add')]"); // the first button is the one we want
49
50 for (int second = 0;; second++) {
51 if (second >= 60) Assert.fail("timeout");
52 try { if ( getAttributeByName("newCollectionLines['list1'].field1","value").equals("")) break; } catch (Exception e) {}
53 Thread.sleep(1000);
54 }
55
56 Assert.assertEquals("",getAttributeByName("newCollectionLines['list1'].field1","value"));
57 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field2","value"));
58 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field3","value"));
59 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field4","value"));
60 Assert.assertEquals("asdf1", getAttributeByName("list1[0].field1","value"));
61 Assert.assertEquals("asdf2", getAttributeByName("list1[0].field2","value"));
62 Assert.assertEquals("asdf3", getAttributeByName("list1[0].field3","value"));
63 Assert.assertEquals("asdf4", getAttributeByName("list1[0].field4","value"));
64
65 Assert.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"));
66 passed();
67 }
68
69
70 private void assertTableLayout() {
71 Assert.assertTrue(driver.getPageSource().contains("Table Layout"));
72 Assert.assertTrue(driver.getPageSource().contains("Field 1"));
73 Assert.assertTrue(driver.getPageSource().contains("Field 2"));
74 Assert.assertTrue(driver.getPageSource().contains("Field 3"));
75 Assert.assertTrue(driver.getPageSource().contains("Field 4"));
76 Assert.assertTrue(driver.getPageSource().contains("Actions"));
77 }
78
79
80
81
82 @Test
83 public void testAddBlankLine() throws Exception {
84 waitAndClickByLinkText("Add Blank Line");
85 waitAndClickByXpath("//button[contains(.,'Add Line')]");
86 Thread.sleep(3000);
87 assertElementPresentByName("list1[0].field1");
88
89 assertTableLayout();
90 Assert.assertEquals("", getAttributeByName("list1[0].field1","value"));
91 Assert.assertEquals("", getAttributeByName("list1[0].field2","value"));
92 Assert.assertEquals("", getAttributeByName("list1[0].field3","value"));
93 Assert.assertEquals("", getAttributeByName("list1[0].field4","value"));
94 Assert.assertEquals("5", getAttributeByName("list1[1].field1","value"));
95 Assert.assertEquals("6", getAttributeByName("list1[1].field2","value"));
96 Assert.assertEquals("7", getAttributeByName("list1[1].field3","value"));
97 Assert.assertEquals("8", getAttributeByName("list1[1].field4","value"));
98
99
100 Assert.assertEquals("Total: 419", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
101 waitAndTypeByName("list1[0].field1", "1");
102 waitAndTypeByName("list1[0].field2", "1");
103 waitAndTypeByName("list1[0].field3", "1");
104 waitAndTypeByName("list1[0].field4", "1");
105 Assert.assertEquals("Total: 420", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
106 passed();
107
108 }
109
110
111
112
113
114 @Test
115 public void testActionColumnPlacement() throws Exception {
116
117
118
119
120
121
122
123 waitAndClickByLinkText("Column Sequence");
124 Thread.sleep(2000);
125
126
127
128 for (int second = 0;; second++) {
129 if (second >= 60) Assert.fail("timeout");
130 try { if (isElementPresentByXpath("//tr[2]/td[6]/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
131 Thread.sleep(1000);
132 }
133 Assert.assertTrue(isElementPresentByXpath("//tr[2]/td[6]/div/fieldset/div/div[2]/button"));
134
135
136
137 for (int second = 0;; second++) {
138 if (second >= 60) Assert.fail("timeout");
139 try { if (isElementPresentByXpath("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
140 Thread.sleep(1000);
141 }
142 Assert.assertTrue(isElementPresentByXpath("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button"));
143
144
145
146 for (int second = 0;; second++) {
147 if (second >= 60) Assert.fail("timeout");
148 try { if (isElementPresentByXpath("//tr[2]/td[3]/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
149 Thread.sleep(1000);
150 }
151 Assert.assertTrue(isElementPresentByXpath("//tr[2]/td[3]/div/fieldset/div/div[2]/button"));
152 passed();
153
154 }
155
156
157 @Test
158 public void testAddViaLightbox() throws Exception {
159
160 waitAndClickByLinkText("Add Via Lightbox");
161 Assert.assertEquals("Total: 419", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
162 waitAndClickByXpath("//button[contains(.,'Add Line')]");
163 Thread.sleep(3000);
164 waitAndTypeByXpath("//form/div/table/tbody/tr/td/div/input", "1");
165 waitAndTypeByXpath("//form/div/table/tbody/tr[2]/td/div/input", "1");
166 waitAndTypeByXpath("//form/div/table/tbody/tr[3]/td/div/input", "1");
167 waitAndTypeByXpath("//form/div/table/tbody/tr[4]/td/div/input", "1");
168 waitAndClickByXpath("//button[@id='uif-addLine_add']");
169 Thread.sleep(3000);
170 Assert.assertEquals("Total: 420", driver.findElement(By.xpath("//fieldset/div/div[2]/div[2]")).getText());
171 passed();
172 }
173
174 @Test
175 public void testColumnSequence() throws Exception {
176
177 waitAndClickByLinkText("Column Sequence");
178 Thread.sleep(3000);
179 waitAndTypeByName("newCollectionLines['list1'].field1", "1");
180 waitAndTypeByName("newCollectionLines['list1'].field2", "1");
181 waitAndTypeByName("newCollectionLines['list1'].field3", "1");
182 waitAndTypeByName("newCollectionLines['list1'].field4", "1");
183 waitAndClick(By.id("uif-addLine_add"));
184 Thread.sleep(3000);
185
186
187 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field1","value"));
188 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field2","value"));
189 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field3","value"));
190 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field4","value"));
191 Assert.assertEquals("1", getAttributeByName("list1[0].field1","value"));
192 Assert.assertEquals("1", getAttributeByName("list1[0].field2","value"));
193 Assert.assertEquals("1", getAttributeByName("list1[0].field3","value"));
194 Assert.assertEquals("1", getAttributeByName("list1[0].field4","value"));
195
196
197 Assert.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"));
198 passed();
199 }
200
201 @Test
202 public void testSequencerow() throws Exception {
203 waitAndClickByLinkText("Save Row");
204 Thread.sleep(3000);
205 waitAndTypeByName("newCollectionLines['list1'].field1", "1");
206 waitAndTypeByName("newCollectionLines['list1'].field2", "1");
207 waitAndTypeByName("newCollectionLines['list1'].field3", "1");
208 waitAndTypeByName("newCollectionLines['list1'].field4", "1");
209
210 waitAndClickByXpath("//button[contains(.,'add')]");
211 Thread.sleep(3000);
212
213
214 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field1","value"));
215 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field2","value"));
216 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field3","value"));
217 Assert.assertEquals("", getAttributeByName("newCollectionLines['list1'].field4","value"));
218 Assert.assertEquals("1",getAttributeByName("list1[0].field1","value"));
219 Assert.assertEquals("1",getAttributeByName("list1[0].field2","value"));
220 Assert.assertEquals("1",getAttributeByName("list1[0].field3","value"));
221 Assert.assertEquals("1",getAttributeByName("list1[0].field4","value"));
222
223
224 Assert.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"));
225 Assert.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[@class='uif-action uif-secondaryActionButton uif-smallActionButton uif-saveLineAction']"));
226 passed();
227 }
228
229
230 }