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.ITUtil;
20 import edu.samplu.common.UpgradedSeleniumITBase;
21 import org.junit.Assert;
22 import org.junit.Test;
23
24
25
26
27
28
29 public class CollectionsIT extends UpgradedSeleniumITBase {
30
31 @Override
32 public String getTestUrl() {
33 return "/kr-krad/uicomponents?viewId=ConfigurationTestView-Collections&methodToCall=start";
34 }
35
36
37
38
39 @Test
40 public void testDefaultTestsTableLayout() throws Exception{
41
42 Assert.assertTrue(isTextPresent("Default Tests"));
43 assertTableLayout();
44
45 waitAndType("name=newCollectionLines['list1'].field1", "asdf1");
46 waitAndType("name=newCollectionLines['list1'].field2", "asdf2");
47 waitAndType("name=newCollectionLines['list1'].field3", "asdf3");
48 waitAndType("name=newCollectionLines['list1'].field4", "asdf4");
49 waitAndClick("//button[contains(.,'add')]"); // the first button is the one we want
50
51 for (int second = 0;; second++) {
52 if (second >= 60) Assert.fail("timeout");
53 try { if (getValue("name=newCollectionLines['list1'].field1").equals("")) break; } catch (Exception e) {}
54 Thread.sleep(1000);
55 }
56
57 Assert.assertEquals("", getValue("name=newCollectionLines['list1'].field1"));
58 Assert.assertEquals("", getValue("name=newCollectionLines['list1'].field2"));
59 Assert.assertEquals("", getValue("name=newCollectionLines['list1'].field3"));
60 Assert.assertEquals("", getValue("name=newCollectionLines['list1'].field4"));
61 Assert.assertEquals("asdf1", getValue("name=list1[0].field1"));
62 Assert.assertEquals("asdf2", getValue("name=list1[0].field2"));
63 Assert.assertEquals("asdf3", getValue("name=list1[0].field3"));
64 Assert.assertEquals("asdf4", getValue("name=list1[0].field4"));
65
66 }
67
68 private void assertTableLayout() {
69 Assert.assertTrue(isTextPresent("Table Layout"));
70 Assert.assertTrue(isTextPresent("* Field 1"));
71 Assert.assertTrue(isTextPresent("* Field 2"));
72 Assert.assertTrue(isTextPresent("* Field 3"));
73 Assert.assertTrue(isTextPresent("* Field 4"));
74 Assert.assertTrue(isTextPresent("Actions"));
75 }
76
77
78
79
80 @Test
81 public void testAddBlankLine() throws Exception {
82 waitAndClick("link=Add Blank Line");
83 waitAndClick("//button[contains(.,'Add Line')]");
84
85 waitForElementPresent("name=list1[0].field1");
86 assertTableLayout();
87 Assert.assertEquals("", getValue("name=list1[0].field1"));
88 Assert.assertEquals("", getValue("name=list1[0].field2"));
89 Assert.assertEquals("", getValue("name=list1[0].field3"));
90 Assert.assertEquals("", getValue("name=list1[0].field4"));
91 Assert.assertEquals("5", getValue("name=list1[1].field1"));
92 Assert.assertEquals("6", getValue("name=list1[1].field2"));
93 Assert.assertEquals("7", getValue("name=list1[1].field3"));
94 Assert.assertEquals("8", getValue("name=list1[1].field4"));
95
96 }
97
98
99
100
101
102
103 @Test
104 public void testActionColumnPlacement() throws Exception {
105
106
107
108
109
110
111
112 waitAndClick("link=Column Sequence");
113 Thread.sleep(2000);
114
115
116
117 for (int second = 0;; second++) {
118 if (second >= 60) Assert.fail("timeout");
119 try { if (isElementPresent("//tr[2]/td[6]/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
120 Thread.sleep(1000);
121 }
122 Assert.assertTrue(isElementPresent("//tr[2]/td[6]/div/fieldset/div/div[2]/button"));
123
124
125
126 for (int second = 0;; second++) {
127 if (second >= 60) Assert.fail("timeout");
128 try { if (isElementPresent("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
129 Thread.sleep(1000);
130 }
131 Assert.assertTrue(isElementPresent("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td/div/fieldset/div/div[2]/button"));
132
133
134
135 for (int second = 0;; second++) {
136 if (second >= 60) Assert.fail("timeout");
137 try { if (isElementPresent("//tr[2]/td[3]/div/fieldset/div/div[2]/button")) break; } catch (Exception e) {}
138 Thread.sleep(1000);
139 }
140 Assert.assertTrue(isElementPresent("//tr[2]/td[3]/div/fieldset/div/div[2]/button"));
141
142
143 }
144 }