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 021 import java.util.List; 022 023 import org.junit.Test; 024 import org.openqa.selenium.By; 025 import org.openqa.selenium.WebElement; 026 027 import edu.samplu.common.ITUtil; 028 import edu.samplu.common.WebDriverLegacyITBase; 029 030 031 /** 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034 public class DocSearchWDIT extends WebDriverLegacyITBase { 035 036 String docId; 037 String parentName; 038 @Override 039 public String getTestUrl(){ 040 return ITUtil.PORTAL; 041 } 042 043 public void createAndSaveDoc() throws Exception{ 044 waitForTitleToEqualKualiPortalIndex(); 045 waitAndClickByLinkText("Administration"); 046 waitForTitleToEqualKualiPortalIndex(); 047 waitAndClickByLinkText("Document Type"); 048 waitForTitleToEqualKualiPortalIndex(); 049 selectFrame("iframeportlet"); 050 waitAndClickByXpath("//img[contains(@alt,'create new')]"); 051 waitForPageToLoad(); 052 Thread.sleep(2000); 053 assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page"); 054 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"); 055 docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText(); 056 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type"); 057 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']"; 058 waitAndClickByXpath(parentDocType); 059 waitForPageToLoad(); 060 //Thread.sleep(2000); 061 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']"); 062 waitForPageToLoad(); 063 parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText(); 064 waitAndClickByLinkText("return value"); 065 String docTypeName = "TestDocType " + ITUtil.DTS; 066 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']"); 067 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName); 068 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler"); 069 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA"); 070 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label"); 071 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm"); 072 waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']"); 073 //checkForIncidentReport(); 074 selectTopFrame(); 075 } 076 @Test 077 public void testBasicDocSearch() throws Exception { 078 createAndSaveDoc(); 079 waitAndClickByXpath("//a/img[@alt='doc search']"); 080 waitForPageToLoad(); 081 selectFrame("iframeportlet"); 082 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']"); 083 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']"); 084 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']"); 085 waitAndTypeByName("documentTypeName", parentName); 086 waitAndTypeByName("initiatorPrincipalName", "admin"); 087 waitAndTypeByName("documentId", docId); 088 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010"); 089 //waitAndTypeByName("dateCreated", "10/13/2010"); 090 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']"); 091 waitForPageToLoad(); 092 assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText()); 093 //Thread.sleep(2000); 094 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']"); 095 assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value")); 096 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value")); 097 assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value")); 098 assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value")); 099 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 //createAndSaveDoc(); 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 //waitAndTypeByName("documentTypeName", parentName); 118 waitAndTypeByName("initiatorPrincipalName", "admin"); 119 //waitAndTypeByName("documentId", docId); 120 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010"); 121 //waitAndTypeByName("dateCreated", "10/13/2010"); 122 assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search"); 123 //waitAndTypeByName("approverPrincipalName", "director"); 124 assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search"); 125 //waitAndTypeByName("viewerPrincipalName", "superviser"); 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 //Thread.sleep(2000); 133 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']"); 134 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value")); 135 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value")); 136 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value")); 137 //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value")); 138 //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value")); 139 waitAndClickByXpath("//a[@title='cancel']"); 140 waitForPageToLoad(); 141 } 142 143 @Test 144 public void testSuperUserSearch() throws Exception{ 145 //createAndSaveDoc(); 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 //Thread.sleep(4000); 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 }