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