001 /**
002 * Copyright 2005-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package edu.samplu.admin.test;
018
019 import static org.junit.Assert.assertEquals;
020 import static org.junit.Assert.assertTrue;
021
022 import java.util.List;
023
024 import org.junit.Assert;
025 import org.junit.Ignore;
026 import org.junit.Test;
027 import org.openqa.selenium.By;
028 import org.openqa.selenium.WebElement;
029
030 import edu.samplu.common.ITUtil;
031 import edu.samplu.common.WebDriverLegacyITBase;
032
033 /**
034 * @author Kuali Rice Team (rice.collab@kuali.org)
035 */
036 public class DocSearchWDIT extends WebDriverLegacyITBase {
037
038 String docId;
039 String parentName;
040
041 @Override
042 public void fail(String message) {
043 Assert.fail(message);
044 }
045
046 @Override
047 public String getTestUrl(){
048 return ITUtil.PORTAL;
049 }
050
051 public void createAndSaveDoc() throws Exception{
052 waitForTitleToEqualKualiPortalIndex();
053 waitAndClickByLinkText("Administration");
054 waitForTitleToEqualKualiPortalIndex();
055 waitAndClickByLinkText("Document Type");
056 waitForTitleToEqualKualiPortalIndex();
057 selectFrame("iframeportlet");
058 waitAndClickByXpath("//img[contains(@alt,'create new')]");
059 waitForPageToLoad();
060 Thread.sleep(2000);
061 assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page");
062 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
063 docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
064 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type");
065 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']";
066 waitAndClickByXpath(parentDocType);
067 waitForPageToLoad();
068 //Thread.sleep(2000);
069 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
070 waitForPageToLoad();
071 parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText();
072 waitAndClickByLinkText("return value");
073 String docTypeName = "TestDocType " + ITUtil.DTS;
074 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
075 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
076 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler");
077 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
078 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label");
079 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm");
080 waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
081 // TODO wait for save confirmation
082 //checkForIncidentReport();
083 selectTopFrame();
084 }
085 @Test
086 public void testBasicDocSearch() throws Exception {
087 createAndSaveDoc();
088 waitAndClickByXpath("//a/img[@alt='doc search']");
089 waitForPageToLoad();
090 selectFrame("iframeportlet");
091 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
092 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
093 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
094 waitAndTypeByName("documentTypeName", parentName);
095 waitAndTypeByName("initiatorPrincipalName", "admin");
096 waitAndTypeByName("documentId", docId);
097 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
098 //waitAndTypeByName("dateCreated", "10/13/2010");
099 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
100 waitForPageToLoad();
101 assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
102 //Thread.sleep(2000);
103 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
104 assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
105 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
106 assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
107 assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
108 assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
109 waitAndClickByXpath("//a[@title='cancel']");
110 waitForPageToLoad();
111 passed();
112 }
113
114 @Ignore // TODO fix
115 @Test
116 public void testDetailedDocSearch() throws Exception{
117 //createAndSaveDoc();
118 waitAndClickByXpath("//a/img[@alt='doc search']");
119 waitForPageToLoad();
120 selectFrame("iframeportlet");
121 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
122 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
123 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
124 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
125 waitForPageToLoad();
126 assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']");
127 //waitAndTypeByName("documentTypeName", parentName);
128 waitAndTypeByName("initiatorPrincipalName", "admin");
129 //waitAndTypeByName("documentId", docId);
130 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
131 //waitAndTypeByName("dateCreated", "10/13/2010");
132 assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
133 //waitAndTypeByName("approverPrincipalName", "director");
134 assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
135 //waitAndTypeByName("viewerPrincipalName", "superviser");
136 assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
137 selectByXpath("//select[@id='statusCode']", "- SAVED");
138 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
139 waitForPageToLoad();
140 assertTrue(driver.findElement(By.id("row")).getText().contains("SAVED"));
141 assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
142 //Thread.sleep(2000);
143 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
144 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
145 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
146 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
147 //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
148 //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
149 waitAndClickByXpath("//a[@title='cancel']");
150 waitForPageToLoad();
151 passed();
152 }
153
154 @Test
155 public void testSuperUserSearch() throws Exception{
156 //createAndSaveDoc();
157 waitAndClickByXpath("//a/img[@alt='doc search']");
158 waitForPageToLoad();
159 selectFrame("iframeportlet");
160 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
161 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
162 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
163 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
164 waitForPageToLoad();
165 assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']");
166 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
167 waitForPageToLoad();
168 waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
169 selectTopFrame();
170 Thread.sleep(3000);
171 switchToWindow("Kuali :: Superuser Document Service");
172 waitForPageToLoad();
173 //Thread.sleep(4000);
174
175 waitAndClickByXpath("//input[@src='images/buttonsmall_complete.gif']");
176 waitForPageToLoad();
177 assertElementPresentByName("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 waitForPageToLoad();
182 waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
183 waitForPageToLoad();
184 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
185 waitForPageToLoad();
186 assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
187 passed();
188 }
189
190 @Test
191 public void testClearSavedSearches() throws Exception{
192 waitAndClickByXpath("//a/img[@alt='doc search']");
193 waitForPageToLoad();
194 selectFrame("iframeportlet");
195 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
196 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
197 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
198 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
199 waitForPageToLoad();
200 WebElement select1 = driver.findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
201 List<WebElement> options = select1.findElements(By.tagName("option"));
202 int count= options.size();
203 assertEquals(5,count);
204 passed();
205 }
206
207 @Test
208 public void testAjaxPageReload() throws Exception{
209 waitAndClickByXpath("//a/img[@alt='doc search']");
210 waitForPageToLoad();
211 selectFrame("iframeportlet");
212 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
213 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
214 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
215 waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
216 waitAndTypeByName("documentTypeName", "KualiNotification");
217 Thread.sleep(2000);
218 fireEvent("documentTypeName", "blur");
219 Thread.sleep(1000);
220 assertElementPresentByName("documentAttribute.notificationContentType");
221 assertElementPresentByName("documentAttribute.notificationChannel");
222 assertElementPresentByName("documentAttribute.notificationProducer");
223 assertElementPresentByName("documentAttribute.notificationPriority");
224 assertElementPresentByName("documentAttribute.notificationRecipients");
225 assertElementPresentByName("documentAttribute.notificationSenders");
226 waitAndClickByXpath("//a[@title='cancel']");
227 passed();
228 }
229 }