View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @author Kuali Rice Team (rice.collab@kuali.org)
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); // TODO wait for save confirmation
70          checkForIncidentReport();
71          selectTopFrame();
72      }
73      @Test
74      public void testBasicDocSearchBookmark() throws Exception {
75          createAndSaveDoc();
76          waitAndClickByXpath("//a/img[@alt='doc search']");
77          waitForPageToLoad();
78          selectFrame("iframeportlet");
79          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
80          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
81          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
82          waitAndTypeByName("documentTypeName", "DocumentTypeDocument");
83          waitAndTypeByName("initiatorPrincipalName", "admin");
84          waitAndTypeByName("documentId", docId);
85          //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
86          //waitAndTypeByName("dateCreated", "10/13/2010");
87          waitAndClickMethodToCallSearchButton();
88          selectFrameIframePortlet();
89          assertEquals(docId, waitFor(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
90          //Thread.sleep(2000);
91          waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
92          assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
93          assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
94          assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
95          assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
96          assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
97          waitAndClickByXpath("//a[@title='cancel']");
98          passed();
99      }
100 
101     @Test
102     public void testBasicFullDocSearchBookmark() throws Exception {
103         waitAndClickByXpath("//a/img[@alt='doc search']");
104         waitForPageToLoad();
105         selectFrame("iframeportlet");
106         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
107         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
108         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
109         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "1/1/1900"); // remove default today's date
110         waitAndClickMethodToCallSearchButton();
111         waitForTextPresent("Export options:");
112         passed();
113     }
114 
115     @Test
116     public void testDetailedDocSearchBookmark() 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         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']", "DocSearchAft.testDetailedDocSearch");
126         //waitAndTypeByName("documentTypeName", parentName);
127         waitAndTypeByName("initiatorPrincipalName", "admin");
128         waitAndTypeByName("documentId", docId);
129         //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
130         //waitAndTypeByName("dateCreated", "10/13/2010");
131         assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
132         //waitAndTypeByName("approverPrincipalName", "director");
133         assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
134         //waitAndTypeByName("viewerPrincipalName", "superviser");
135         assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
136         selectByXpath("//select[@id='statusCode']", "- SAVED");
137         waitAndClickMethodToCallSearchButton();
138         assertTextNotPresent("No values match this search.");
139         assertTrue(driver.findElement(By.id("row")).getText().contains("SAVED"));
140         assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
141         //Thread.sleep(2000);
142         waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
143         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).waitAndGetAttribute("value"));
144         assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
145         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).waitAndGetAttribute("value"));
146         //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).waitAndGetAttribute("value"));
147         //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).waitAndGetAttribute("value"));
148         waitAndClickByXpath("//a[@title='cancel']");
149         passed();
150     }
151     
152     @Test
153     public void testSuperUserSearchBookmark() throws Exception{
154         createAndSaveDoc();
155         waitAndClickByXpath("//a/img[@alt='doc search']");
156         waitForPageToLoad();
157         selectFrame("iframeportlet");
158         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
159         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
160         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
161         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
162         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']",
163                 "DocSearchAft.testSuperUserSearch");
164         waitAndClickMethodToCallSearchButton();
165         Thread.sleep(3000);
166         selectFrameIframePortlet();
167         waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
168         selectTopFrame();
169         Thread.sleep(3000);
170         switchToWindow("Kuali :: Superuser Document Service");
171         waitForPageToLoad();
172         //Thread.sleep(4000);
173 
174         waitAndClickByXpath("//input[@src='images/buttonsmall_complete.gif']");
175         waitForElementPresentByName("methodToCall.approve", "approve button does not exist on the page");
176         assertElementPresentByName("methodToCall.disapprove", "disapprove button does not exist on the page");
177         assertElementPresentByName("methodToCall.cancel", "cancel button does not exist on the page");
178         waitAndClickByName("methodToCall.approve", "approve button does not exist on the page");
179         jGrowl("Click Cancel Button");
180         waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
181         waitAndTypeByName("documentId", docId);
182         waitAndClickMethodToCallSearchButton();
183         waitForPageToLoad();
184         assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
185         passed();
186     }
187 
188     protected void waitAndClickMethodToCallSearchButton() throws InterruptedException {
189         jGrowl("Click Search Button");
190         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
191     }
192 
193     @Test
194     public void testClearSavedSearchesBookmark() throws Exception{
195         waitAndClickByXpath("//a/img[@alt='doc search']");
196         waitForPageToLoad();
197         selectFrame("iframeportlet");
198         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
199         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
200         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
201         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
202         waitForPageToLoad();
203         WebElement select1 = findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
204         List<WebElement> options = select1.findElements(By.tagName("option"));
205         int count= options.size();
206         assertEquals(5,count);
207         passed();
208     }
209     
210     @Test
211     public void testAjaxPageReloadBookmark() throws Exception{
212         waitAndClickByXpath("//a/img[@alt='doc search']");
213         waitForPageToLoad();
214         selectFrame("iframeportlet");
215         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
216         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
217         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
218         waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
219         waitAndTypeByName("documentTypeName", "KualiNotification");
220         fireEvent("documentTypeName", "blur");
221         waitForElementPresentByName("documentAttribute.notificationContentType");
222         assertElementPresentByName("documentAttribute.notificationChannel");
223         assertElementPresentByName("documentAttribute.notificationProducer");
224         assertElementPresentByName("documentAttribute.notificationPriority");
225         assertElementPresentByName("documentAttribute.notificationRecipients");
226         assertElementPresentByName("documentAttribute.notificationSenders");
227         waitAndClickByXpath("//a[@title='cancel']");
228         passed();
229     }
230 }