View Javadoc

1   /**
2    * Copyright 2005-2011 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  
17  package edu.samplu.admin.test;
18  
19  import static org.junit.Assert.assertEquals;
20  import static org.junit.Assert.assertTrue;
21  
22  import java.util.List;
23  
24  import org.junit.Assert;
25  import org.junit.Ignore;
26  import org.junit.Test;
27  import org.openqa.selenium.By;
28  import org.openqa.selenium.WebElement;
29  
30  import edu.samplu.common.ITUtil;
31  import edu.samplu.common.WebDriverLegacyITBase;
32  
33  /**
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   */
36  public class DocSearchWDIT extends WebDriverLegacyITBase {
37  
38      String docId;
39      String parentName;
40  
41      @Override
42      public void fail(String message) {
43          Assert.fail(message);
44      }
45  
46      @Override
47      public String getTestUrl(){
48          return ITUtil.PORTAL;
49      }
50      
51      public void createAndSaveDoc() throws Exception{
52          waitForTitleToEqualKualiPortalIndex();
53          waitAndClickByLinkText("Administration");
54          waitForTitleToEqualKualiPortalIndex();
55          waitAndClickByLinkText("Document Type");
56          waitForTitleToEqualKualiPortalIndex();
57          selectFrame("iframeportlet");
58          waitAndClickByXpath("//img[contains(@alt,'create new')]");
59          waitForPageToLoad();
60          Thread.sleep(2000);
61          assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page");
62          waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
63          docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
64          waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type");
65          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']";
66          waitAndClickByXpath(parentDocType);
67          waitForPageToLoad();
68          //Thread.sleep(2000);
69          waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
70          waitForPageToLoad();
71          parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText();
72          waitAndClickByLinkText("return value");
73          String docTypeName = "TestDocType " + ITUtil.DTS;
74          waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
75          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
76          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler");
77          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
78          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label");
79          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm");
80          waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
81          // TODO wait for save confirmation
82          //checkForIncidentReport();
83          selectTopFrame();
84      }
85      @Test
86      public void testBasicDocSearch() throws Exception {
87          createAndSaveDoc();
88          waitAndClickByXpath("//a/img[@alt='doc search']");
89          waitForPageToLoad();
90          selectFrame("iframeportlet");
91          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
92          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
93          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
94          waitAndTypeByName("documentTypeName", parentName);
95          waitAndTypeByName("initiatorPrincipalName", "admin");
96          waitAndTypeByName("documentId", docId);
97          //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
98          //waitAndTypeByName("dateCreated", "10/13/2010");
99          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 }