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.Test;
26  import org.openqa.selenium.By;
27  import org.openqa.selenium.WebElement;
28  
29  import edu.samplu.common.ITUtil;
30  import edu.samplu.common.WebDriverLegacyITBase;
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          // TODO wait for save confirmation
81          //checkForIncidentReport();
82          selectTopFrame();
83      }
84      @Test
85      public void testBasicDocSearch() throws Exception {
86          createAndSaveDoc();
87          waitAndClickByXpath("//a/img[@alt='doc search']");
88          waitForPageToLoad();
89          selectFrame("iframeportlet");
90          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
91          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
92          waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
93          waitAndTypeByName("documentTypeName", parentName);
94          waitAndTypeByName("initiatorPrincipalName", "admin");
95          waitAndTypeByName("documentId", docId);
96          //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
97          //waitAndTypeByName("dateCreated", "10/13/2010");
98          waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
99          waitForPageToLoad();
100         assertEquals(docId, driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
101         //Thread.sleep(2000);
102         waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
103         assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
104         assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
105         assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
106         assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
107         assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
108         waitAndClickByXpath("//a[@title='cancel']");
109         waitForPageToLoad();
110         
111     }
112     
113     @Test
114     public void testDetailedDocSearch() throws Exception{
115         //createAndSaveDoc();
116         waitAndClickByXpath("//a/img[@alt='doc search']");
117         waitForPageToLoad();
118         selectFrame("iframeportlet");
119         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
120         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
121         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
122         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
123         waitForPageToLoad();
124         assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']");
125         //waitAndTypeByName("documentTypeName", parentName);
126         waitAndTypeByName("initiatorPrincipalName", "admin");
127         //waitAndTypeByName("documentId", docId);
128         //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
129         //waitAndTypeByName("dateCreated", "10/13/2010");
130         assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
131         //waitAndTypeByName("approverPrincipalName", "director");
132         assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
133         //waitAndTypeByName("viewerPrincipalName", "superviser");
134         assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
135         selectByXpath("//select[@id='statusCode']", "- SAVED");
136         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
137         waitForPageToLoad();
138         assertTrue(driver.findElement(By.id("row")).getText().contains("SAVED"));
139         assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
140         //Thread.sleep(2000);
141         waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
142         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
143         assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
144         //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
145         //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
146         //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
147         waitAndClickByXpath("//a[@title='cancel']");
148         waitForPageToLoad();
149     }
150     
151     @Test
152     public void testSuperUserSearch() throws Exception{
153         //createAndSaveDoc();
154         waitAndClickByXpath("//a/img[@alt='doc search']");
155         waitForPageToLoad();
156         selectFrame("iframeportlet");
157         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
158         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
159         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
160         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
161         waitForPageToLoad();
162         assertElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']");
163         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
164         waitForPageToLoad();
165         waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
166         selectTopFrame();
167         Thread.sleep(3000);
168         switchToWindow("Kuali :: Superuser Document Service");
169         waitForPageToLoad();
170         //Thread.sleep(4000);
171 
172         waitAndClickByXpath("//input[@src='images/buttonsmall_complete.gif']");
173         waitForPageToLoad();
174         assertElementPresentByName("methodToCall.approve","approve button does not exist on the page");
175         assertElementPresentByName("methodToCall.disapprove","disapprove button does not exist on the page");
176         assertElementPresentByName("methodToCall.cancel","cancel button does not exist on the page");
177         waitAndClickByName("methodToCall.approve","approve button does not exist on the page");
178         waitForPageToLoad();
179         waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
180         waitForPageToLoad();
181         waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
182         waitForPageToLoad();
183         assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
184         
185     }
186     
187     @Test
188     public void testClearSavedSearches() throws Exception{
189         waitAndClickByXpath("//a/img[@alt='doc search']");
190         waitForPageToLoad();
191         selectFrame("iframeportlet");
192         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
193         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
194         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
195         waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
196         waitForPageToLoad();
197         WebElement select1 = driver.findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
198         List<WebElement> options = select1.findElements(By.tagName("option"));
199         int count= options.size();
200         assertEquals(5,count);
201     }
202     
203     @Test
204     public void testAjaxPageReload() throws Exception{
205         waitAndClickByXpath("//a/img[@alt='doc search']");
206         waitForPageToLoad();
207         selectFrame("iframeportlet");
208         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
209         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
210         waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
211         waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
212         waitAndTypeByName("documentTypeName", "KualiNotification");
213         Thread.sleep(2000);
214         fireEvent("documentTypeName", "blur");
215         waitForPageToLoad();
216         assertElementPresentByName("documentAttribute.notificationContentType");
217         assertElementPresentByName("documentAttribute.notificationChannel");
218         assertElementPresentByName("documentAttribute.notificationProducer");
219         assertElementPresentByName("documentAttribute.notificationPriority");
220         assertElementPresentByName("documentAttribute.notificationRecipients");
221         assertElementPresentByName("documentAttribute.notificationSenders");
222         waitAndClickByXpath("//a[@title='cancel']");
223     }
224     
225 }