1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.admin;
17
18 import org.junit.Test;
19 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21 import org.kuali.rice.testtools.selenium.WebDriverUtils;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.WebElement;
24
25 import java.util.List;
26
27 import static org.junit.Assert.assertEquals;
28
29
30
31
32 public class DocSearchAft extends WebDriverLegacyITBase {
33
34 public static String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Type&channelUrl=" + WebDriverUtils
35 .getBaseUrlString() + "/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.kew.doctype.bo.DocumentType&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
36
37 String docId;
38 String parentName;
39
40 @Override
41 protected String getBookmarkUrl() {
42 return BOOKMARK_URL;
43 }
44
45 public void createAndSaveDoc() throws Exception{
46 waitForTitleToEqualKualiPortalIndex();
47 waitAndClickByLinkText("Administration");
48 waitForTitleToEqualKualiPortalIndex();
49 waitAndClickByLinkText("Document Type");
50 waitForTitleToEqualKualiPortalIndex();
51 selectFrame("iframeportlet");
52 waitAndClickByXpath("//img[contains(@alt,'create new')]");
53 waitForElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page");
54 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
55 docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
56 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type");
57 String parentDocType = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:document.newMaintainableObject.parentDocType.name,documentTypeId:document.newMaintainableObject.docTypeParentId,))).((`document.newMaintainableObject.parentDocType.name:name,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']";
58 waitAndClickByXpath(parentDocType);
59 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
60 waitForPageToLoad();
61 parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText();
62 waitAndClickByLinkText("return value");
63 String docTypeName = "TestDocType " + AutomatedFunctionalTestUtils.DTS;
64 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
65 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
66 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler");
67 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
68 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label");
69 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm");
70 waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
71
72
73 selectTopFrame();
74 }
75 @Test
76 public void testBasicDocSearchBookmark() throws Exception {
77 createAndSaveDoc();
78 waitAndClickByXpath("//a/img[@alt='doc search']");
79 waitForPageToLoad();
80 selectFrame("iframeportlet");
81 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
82 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
83 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
84 waitAndTypeByName("documentTypeName", "DocumentTypeDocument");
85 waitAndTypeByName("initiatorPrincipalName", "admin");
86 waitAndTypeByName("documentId", docId);
87
88
89 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
90 assertEquals(docId, waitFor(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
91
92 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
93 assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
94 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
95 assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
96 assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
97 assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
98 waitAndClickByXpath("//a[@title='cancel']");
99 }
100
101 @Test
102 public void testBasicFullDocSearchBookmark() throws Exception {
103 waitAndClickByXpath("//a/img[@alt='doc search']");
104 waitForPageToLoad();
105 selectFrame("iframeportlet");
106 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
107 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
108 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
109 waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "1/1/1900");
110 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
111 waitForTextPresent("Export options:");
112 }
113
114 @Test
115 public void testDetailedDocSearchBookmark() throws Exception{
116 createAndSaveDoc();
117 waitAndClickByXpath("//a/img[@alt='doc search']");
118 waitForPageToLoad();
119 selectFrame("iframeportlet");
120 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
121 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
122 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
123 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
124 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']", "DocSearchAft.testDetailedDocSearch");
125
126 waitAndTypeByName("initiatorPrincipalName", "admin");
127 waitAndTypeByName("documentId", docId);
128
129
130 assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
131
132 assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
133
134 assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
135 selectByXpath("//select[@id='statusCode']", "- SAVED");
136 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
137 waitForPageToLoad();
138 assertTrue(driver.findElement(By.id("row")).getText().contains("SAVED"));
139 assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
140
141 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
142
143 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
144
145
146
147 waitAndClickByXpath("//a[@title='cancel']");
148 passed();
149 }
150
151 @Test
152 public void testSuperUserSearchBookmark() throws Exception{
153 createAndSaveDoc();
154 waitAndClickByXpath("//a/img[@alt='doc search']");
155 waitForPageToLoad();
156 selectFrame("iframeportlet");
157 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
158 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
159 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
160 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
161 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']", "DocSearchAft.testSuperUserSearch");
162 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
163 waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
164 selectTopFrame();
165 Thread.sleep(3000);
166 switchToWindow("Kuali :: Superuser Document Service");
167 waitForPageToLoad();
168
169
170 waitAndClickByXpath("//input[@src='images/buttonsmall_complete.gif']");
171 waitForElementPresentByName("methodToCall.approve","approve button does not exist on the page");
172 assertElementPresentByName("methodToCall.disapprove","disapprove button does not exist on the page");
173 assertElementPresentByName("methodToCall.cancel","cancel button does not exist on the page");
174 waitAndClickByName("methodToCall.approve","approve button does not exist on the page");
175 waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
176 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
177 waitForPageToLoad();
178 assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
179 passed();
180 }
181
182 @Test
183 public void testClearSavedSearchesBookmark() throws Exception{
184 waitAndClickByXpath("//a/img[@alt='doc search']");
185 waitForPageToLoad();
186 selectFrame("iframeportlet");
187 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
188 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
189 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
190 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
191 waitForPageToLoad();
192 WebElement select1 = findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
193 List<WebElement> options = select1.findElements(By.tagName("option"));
194 int count= options.size();
195 assertEquals(5,count);
196 passed();
197 }
198
199 @Test
200 public void testAjaxPageReloadBookmark() throws Exception{
201 waitAndClickByXpath("//a/img[@alt='doc search']");
202 waitForPageToLoad();
203 selectFrame("iframeportlet");
204 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
205 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
206 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
207 waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
208 waitAndTypeByName("documentTypeName", "KualiNotification");
209 Thread.sleep(2000);
210 fireEvent("documentTypeName", "blur");
211 waitForElementPresentByName("documentAttribute.notificationContentType");
212 assertElementPresentByName("documentAttribute.notificationChannel");
213 assertElementPresentByName("documentAttribute.notificationProducer");
214 assertElementPresentByName("documentAttribute.notificationPriority");
215 assertElementPresentByName("documentAttribute.notificationRecipients");
216 assertElementPresentByName("documentAttribute.notificationSenders");
217 waitAndClickByXpath("//a[@title='cancel']");
218 passed();
219 }
220 }