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 org.kuali.rice.krad.demo.travel.account;
17  
18  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19  import org.junit.Test;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoTravelAccountLookUpAutoSearchAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/lookup?methodToCall=search&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&lookupCriteria['number']=a*&readOnlyFields=number&hideReturnLink=true&showMaintenanceLinks=true
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=search&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&lookupCriteria['number']=a*&readOnlyFields=number&hideReturnLink=true&showMaintenanceLinks=true";
31      
32      /**
33       * Search
34       */
35      public static final String SEARCH = "Search";
36      
37      /**
38       * Clear Values
39       */
40      public static final String CLEAR_VALUES = "Clear Values";
41      
42      @Override
43      public String getBookmarkUrl() {
44          return BOOKMARK_URL;
45      }
46  
47      public void navigate() throws Exception {
48          waitAndClickById("Demo-DemoLink", "");
49          waitAndClickByLinkText("Account Lookup Auto Search Pre-Filtered");
50      }
51  
52      protected void testDemoTravelAccountLookUpAutoSearch() throws Exception {
53          waitForTextPresent("Showing 1 to 10");
54  
55          By[] results = {By.linkText("a1"), By.linkText("a2"), By.linkText("a3"), By.linkText("a4"), By.linkText("a5"),
56                  By.linkText("a6"), By.linkText("a7"), By.linkText("a8"), By.linkText("a9"), By.linkText("a10"),
57                  By.linkText("a11"), By.linkText("a12"), By.linkText("a13"), By.linkText("a14")};
58  
59          assertElementsPresentInResultPages(results);
60          waitAndClickByXpath("//div[@data-label='Travel Account Type Code']/div/div/button[@class='btn btn-default uif-action icon-search']");
61      	waitSearchAndReturnFromLightbox();
62  
63  // TODO should the foid work?
64  //        waitAndTypeByName("lookupCriteria[foId]","1");
65  //        waitAndClickButtonByText(SEARCH);
66  //        Thread.sleep(3000);
67  //        assertElementPresentByXpath("//a[contains(text(), 'a1')]");
68  //        if(isElementPresentByLinkText("a2") || isElementPresentByLinkText("a3")) {
69  //            fail("Search Functionality not working properly.");
70  //        }
71      }
72  
73      @Test
74      public void testDemoTravelAccountLookUpAutoSearchNav() throws Exception {
75          testDemoTravelAccountLookUpAutoSearch();
76          passed();
77      }
78  
79      @Test
80      public void testDemoTravelAccountLookUpAutoSearchBookmark() throws Exception {
81          testDemoTravelAccountLookUpAutoSearch();
82          passed();
83      }
84      
85      private void waitSearchAndReturnFromLightbox() throws Exception {
86      	gotoLightBox();
87      	waitAndClickButtonByText("Search");
88      	waitAndClickByLinkText("return value");
89      }
90  }