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