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