View Javadoc
1   /**
2    * Copyright 2005-2015 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 org.kuali.rice.krad.demo.lookup;
17  
18  import org.kuali.rice.krad.demo.ViewDemoAftBase;
19  import org.openqa.selenium.By;
20  import org.junit.Test;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoLookUpAft extends ViewDemoAftBase {
26  
27      /**
28       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleView&hideReturnLink=true
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleView&hideReturnLink=true";
31  
32      /**
33       *  lookupCriteria[number]
34       */
35      private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
36      
37      /**
38       *  Search
39       */
40      private static final String SEARCH="Search";
41      
42      /**
43       * Clear Values
44       */
45      private static final String CLEAR_VALUES="Clear Values";
46      
47      @Override
48      public String getBookmarkUrl() {
49          return BOOKMARK_URL;
50      }
51  
52      @Override
53      protected void navigate() throws Exception {
54          waitAndClickDemoLink();
55          waitAndClickByLinkText("Lookup");
56      }
57  
58      protected void testLookUp() throws InterruptedException {
59          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
60          waitAndClickButtonByText(SEARCH);
61          Thread.sleep(3000);
62          waitForElementPresentByXpath("//a[contains(text(), 'a1')]");
63          waitAndClickButtonByText(CLEAR_VALUES);
64          waitAndClickButtonByText(SEARCH);
65          waitForElementPresentByXpath("//a[contains(text(), 'a1')]");
66          waitForElementPresentByXpath("//a[contains(text(), 'a6')]");
67          waitAndClickButtonByText(CLEAR_VALUES);
68          waitAndTypeByName("lookupCriteria[name]","Travel Account 1");
69          waitAndClickButtonByText(SEARCH);
70          waitForElementPresentByXpath("//a[contains(text(), 'a1')]");
71          waitForElementNotPresent(By.xpath("//a[contains(text(), 'a2')]"));
72          waitAndClickButtonByText(CLEAR_VALUES);
73          waitAndTypeByName("lookupCriteria[rangeLowerBoundKeyPrefix_createDate]","02/01/2014");
74          waitAndTypeByName("lookupCriteria[createDate]","02/13/2014");
75          waitAndClickButtonByText(SEARCH);
76          waitForTextPresent("No values match this search.");
77      }
78  
79      protected void testLookUpFancy() throws InterruptedException {
80          waitAndTypeByName("lookupCriteria[name]","*");
81          waitAndTypeByName("lookupCriteria[fiscalOfficer.principalName]","eri*");
82          waitAndClickButtonByText(SEARCH);
83          Thread.sleep(3000);
84          waitForElementPresentByXpath("//a[contains(text(), 'a10')]");
85      }
86  
87      @Test
88      public void testLookUpBookmark() throws Exception {
89          testLookUp();
90          passed();
91      }
92  
93      @Test
94      public void testLookUpNav() throws Exception {
95          testLookUp();
96          passed();
97      }
98  
99      @Test
100     public void testLookUpFancyNav() throws Exception {
101         testLookUpFancy();
102         passed();
103     }
104 }