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  
21  import java.util.List;
22  
23  import org.junit.Assert;
24  import org.junit.Test;
25  import org.openqa.selenium.By;
26  import org.openqa.selenium.WebElement;
27  
28  import edu.samplu.common.ITUtil;
29  import edu.samplu.common.WebDriverLegacyITBase;
30  
31  
32  /**
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public class DocSearchWDIT extends WebDriverLegacyITBase {
36  
37      String docId;
38      String parentName;
39  
40      @Override
41      public void fail(String message) {
42          Assert.fail(message);
43      }
44  
45      @Override
46      public String getTestUrl(){
47          return ITUtil.PORTAL;
48      }
49      
50      public void createAndSaveDoc() throws Exception{
51          waitForTitleToEqualKualiPortalIndex();
52          waitAndClickByLinkText("Administration");
53          waitForTitleToEqualKualiPortalIndex();
54          waitAndClickByLinkText("Document Type");
55          waitForTitleToEqualKualiPortalIndex();
56          selectFrame("iframeportlet");
57          waitAndClickByXpath("//img[contains(@alt,'create new')]");
58          waitForPageToLoad();
59          Thread.sleep(2000);
60          assertElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page");
61          waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
62          docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
63          waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type");
64          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']";
65          waitAndClickByXpath(parentDocType);
66          waitForPageToLoad();
67          //Thread.sleep(2000);
68          waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
69          waitForPageToLoad();
70          parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText();
71          waitAndClickByLinkText("return value");
72          String docTypeName = "TestDocType " + ITUtil.DTS;
73          waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
74          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
75          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler");
76          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
77          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label");
78          waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm");
79          waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
80          //checkForIncidentReport();
81          selectTopFrame();
82      }
83      @Test
84      public void testBasicDocSearch() throws Exception {
85          createAndSaveDoc();
86          waitAndClickByXpath("//a/img[@alt='doc search']");
87          waitForPageToLoad();
88          selectFrame("iframeportlet");
89          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
90          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
91          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
92          waitAndTypeByName("documentTypeName", parentName);
93          waitAndTypeByName("initiatorPrincipalName", "admin");
94          waitAndTypeByName("documentId", docId);
95          //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
96          //waitAndTypeByName("dateCreated", "10/13/2010");
97          waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
98          waitForPageToLoad();
99          assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
100         //Thread.sleep(2000);
101         waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
102         assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
103         assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
104         assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
105         assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
106         assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
107         waitAndClickByXpath("//a[@title='cancel']");
108         waitForPageToLoad();
109         
110     }
111     
112     @Test
113     public void testDetailedDocSearch() throws Exception{
114         //createAndSaveDoc();
115         waitAndClickByXpath("//a/img[@alt='doc search']");
116         waitForPageToLoad();
117         selectFrame("iframeportlet");
118         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
119         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
120         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
121         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
122         waitForPageToLoad();
123         assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']");
124         //waitAndTypeByName("documentTypeName", parentName);
125         waitAndTypeByName("initiatorPrincipalName", "admin");
126         //waitAndTypeByName("documentId", docId);
127         //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
128         //waitAndTypeByName("dateCreated", "10/13/2010");
129         assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
130         //waitAndTypeByName("approverPrincipalName", "director");
131         assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
132         //waitAndTypeByName("viewerPrincipalName", "superviser");
133         assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
134         selectByXpath("//select[@id='statusCode']", "- SAVED");
135         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
136         waitForPageToLoad();
137         assertEquals("SAVED", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
138         assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
139         //Thread.sleep(2000);
140         waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
141         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
142         assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
143         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
144         //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
145         //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
146         waitAndClickByXpath("//a[@title='cancel']");
147         waitForPageToLoad();
148     }
149     
150     @Test
151     public void testSuperUserSearch() throws Exception{
152         //createAndSaveDoc();
153         waitAndClickByXpath("//a/img[@alt='doc search']");
154         waitForPageToLoad();
155         selectFrame("iframeportlet");
156         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
157         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
158         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
159         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
160         waitForPageToLoad();
161         assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']");
162         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
163         waitForPageToLoad();
164         waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
165         selectTopFrame();
166         Thread.sleep(3000);
167         switchToWindow("Kuali :: Superuser Document Service");
168         waitForPageToLoad();
169         //Thread.sleep(4000);
170         
171         assertElementPresentByName("methodToCall.actionRequestApprove.(((U))).((`admin`)).(([])).((*2369*)).((%complete%))", "complete button does not exist on the page");
172         waitForElementPresentByName("methodToCall.actionRequestApprove.(((U))).((`admin`)).(([])).((*2369*)).((%complete%))");
173         waitAndClickByName("methodToCall.actionRequestApprove.(((U))).((`admin`)).(([])).((*2369*)).((%complete%))");
174         waitForPageToLoad();
175         assertElementPresentByName("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         waitForPageToLoad();
180         waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
181         waitForPageToLoad();
182         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
183         waitForPageToLoad();
184         assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
185         
186     }
187     
188     @Test
189     public void testClearSavedSearches() throws Exception{
190         waitAndClickByXpath("//a/img[@alt='doc search']");
191         waitForPageToLoad();
192         selectFrame("iframeportlet");
193         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
194         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
195         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
196         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
197         waitForPageToLoad();
198         WebElement select1 = driver.findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
199         List<WebElement> options = select1.findElements(By.tagName("option"));
200         int count= options.size();
201         assertEquals(5,count);
202     }
203     
204     @Test
205     public void testAjaxPageReload() throws Exception{
206         waitAndClickByXpath("//a/img[@alt='doc search']");
207         waitForPageToLoad();
208         selectFrame("iframeportlet");
209         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
210         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
211         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
212         waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
213         waitAndTypeByName("documentTypeName", "KualiNotification");
214         Thread.sleep(2000);
215         fireEvent("documentTypeName", "blur");
216         waitForPageToLoad();
217         assertElementPresentByName("documentAttribute.notificationContentType");
218         assertElementPresentByName("documentAttribute.notificationChannel");
219         assertElementPresentByName("documentAttribute.notificationProducer");
220         assertElementPresentByName("documentAttribute.notificationPriority");
221         assertElementPresentByName("documentAttribute.notificationRecipients");
222         assertElementPresentByName("documentAttribute.notificationSenders");
223         waitAndClickByXpath("//a[@title='cancel']");
224     }
225     
226 }