1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.kitchensink;
17
18 import org.junit.Test;
19 import org.kuali.rice.testtools.selenium.WebDriverUtils;
20
21 import static org.junit.Assert.assertNotSame;
22
23
24
25
26
27 public class LabsCollectionsAft extends LabsKitchenSinkBase {
28
29 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&formKey=ab7fa92d-a2a0-4b94-b349-c00eb81de311&cacheKey=endwmf7mxaohx3lxynk6sm&pageId=UifCompView-Page7#UifCompView-Page7";
30
31 public static final String FIELD_ELEMENT_NAME = "list4[0].subList[0].field1";
32
33 @Override
34 protected String getBookmarkUrl() {
35 return BOOKMARK_URL;
36 }
37
38 @Override
39 protected void navigate() throws Exception {
40 navigateToKitchenSink("Collections");
41 }
42
43 @Test
44 public void testCollectionsBookmark() throws Exception {
45 testCollections();
46 testSubCollectionSize();
47 testDeleteSubCollectionLine();
48 passed();
49 }
50
51 @Test
52 public void testCollectionsNav() throws Exception {
53 testCollections();
54 testSubCollectionSize();
55 testDeleteSubCollectionLine();
56 passed();
57 }
58
59 protected void testCollections() throws InterruptedException {
60
61 waitForTextPresent("Collection Group rendered as a List ", WebDriverUtils.configuredImplicityWait() * 10);
62
63
64 waitForElementPresentByXpath("//table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr[@class='uif-collectionAddItem odd']",
65 "https://jira.kuali.org/browse/RICEQA-274 AFT Failure update LabsCollectionsAft");
66 assertElementPresentByXpath("//table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr/td[@class='uif-collection-column-action ']");
67
68
69 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr[@class='uif-collectionAddItem odd']");
70 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/div[@class='dataTables_length']/label/select");
71 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr/td[1]/div/fieldset/div/button");
72
73
74 assertElementPresentByXpath("//section[@class='uif-collectionItem uif-tableCollectionItem uif-collectionAddItem']/table[@class='table table-condensed table-bordered uif-gridLayout uif-table-fixed']");
75 assertElementPresentByXpath("//div[@class='dataTables_scrollBody']/table[@class='table table-condensed table-bordered uif-tableCollectionLayout dataTable']/tbody/tr/td[@class='uif-collection-column-action ']");
76
77
78 assertElementPresentByXpath("//div[@id='collection3_disclosureContent']/section/table");
79
80
81 assertElementPresentByXpath("//div[@id='collection4_disclosureContent']/section/table");
82 assertElementPresentByXpath("//div[@id='subCollection1_line0_disclosureContent']");
83
84
85 assertElementPresentByXpath("//ul/li/div[@data-parent='UifCompView-CollectionList']");
86 }
87
88 protected void testSubCollectionSize() throws Exception {
89
90 for (int second = 0;; second++) {
91 if (second >= waitSeconds)
92 jiraAwareFail(TIMEOUT_MESSAGE
93 + " looking for "
94 + SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH);
95 try {
96 if (isElementPresentByXpath("//span[@class='uif-headerText-span' and contains(text(),'SubCollection - (3 lines)')]"))
97 {
98 break;
99 }
100 } catch (Exception e) {}
101 Thread.sleep(1000);
102 }
103
104
105 waitForElementPresentByXpath("//section[@id='subCollection1_line0']/header/div/label/a/span[contains(text(),'SubCollection - (3 lines)')]]");
106 waitForElementPresentByXpath("//a[@id='subCollection1_line1_toggle']/span");
107 }
108
109 protected void testDeleteSubCollectionLine() throws Exception {
110
111 waitForElementPresentByName(FIELD_ELEMENT_NAME);
112
113
114 waitAndTypeByName(FIELD_ELEMENT_NAME, "selenium");
115
116
117 waitAndClickById("subCollection1_line0_del_line0_line0");
118 Thread.sleep(2000);
119
120
121 for (int second = 0;; second++) {
122 if (second >= waitSeconds)fail(TIMEOUT_MESSAGE);
123
124 try {
125 if (!"selenium".equals(waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value")))
126 break;
127 } catch (Exception e) {}
128
129 Thread.sleep(1000);
130 }
131
132
133 assertNotSame("selenium", waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value"));
134 }
135 }