View Javadoc
1   /**
2    * Copyright 2005-2013 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 edu.samplu.travel.krad.test;
17  
18  import edu.samplu.common.Failable;
19  import edu.samplu.common.ITUtil;
20  import edu.samplu.common.WebDriverLegacyITBase;
21  
22  import org.junit.Assert;
23  import org.openqa.selenium.Alert;
24  import org.openqa.selenium.By;
25  import org.openqa.selenium.WebElement;
26  
27  import com.thoughtworks.selenium.SeleneseTestBase;
28  
29  /**
30   * Tests the Component section in Rice.
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public abstract class InquiryAbstractSmokeTestBase extends WebDriverLegacyITBase {
35  
36      /**
37       * ITUtil.PORTAL + "?channelTitle=Travel%20Account%20Lookup&channelUrl="
38       * + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
39       * +"edu.sampleu.travel.bo.TravelAccount&returnLocation="
40       * + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS
41       */
42      public static final String BOOKMARK_URL = ITUtil.PORTAL
43              + "?channelTitle=Travel%20Account%20Lookup&channelUrl="
44              + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
45              + "edu.sampleu.travel.bo.TravelAccount"
46              + "&returnLocation=" + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS;
47  
48      /**
49       * //*[contains(button,"Search")]/button
50       */
51      public static final String SEARCH_BUTTON_XPATH ="//div[contains(button, 'Search')]/button[3]";
52      
53      /**
54       * lookupCriteria
55       */
56      public static final String CRITERIA_NAME="lookupCriteria";
57      
58      /**
59       * //iframe[@class='fancybox-iframe']
60       */
61      public static final String FANCYBOX_IFRAME_XPATH="//iframe[@class='fancybox-iframe']";
62      
63      /**
64       * Nav tests start at {@link edu.samplu.common.ITUtil#PORTAL}.  Bookmark Tests should override and return {@link TravelAccountTypeLookupAbstractSmokeTestBase#BOOKMARK_URL}
65       * {@inheritDoc}
66       * @return
67       */    
68      @Override
69      public String getTestUrl() {
70          return ITUtil.PORTAL;
71      }
72  
73      protected void navigation() throws Exception {
74          waitAndClickKRAD();
75          //waitAndClickByLinkText(TRAVEL_ACCOUNT_LOOKUP_LINK_TEXT);
76          waitAndClickByXpath("(//a[contains(text(),'Travel Account Lookup')])[3]");
77      }
78  
79      protected void testInquiryNav(Failable failable) throws Exception {
80          navigation();
81          testInquiry();
82          passed();
83      }
84  
85      protected void testInquiryBookmark(Failable failable) throws Exception {
86          testInquiry();
87          passed();
88      }
89  
90      protected void testInquiry() throws Exception {
91          selectFrameIframePortlet();
92          waitAndTypeByName(CRITERIA_NAME+"[number]", "a1");
93          waitAndClickByXpath("//*[@alt='Direct Inquiry']");
94          selectTopFrame();
95          Thread.sleep(5000);
96          WebElement iframe1 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
97          driver.switchTo().frame(iframe1);
98          SeleneseTestBase.assertEquals("Travel Account Inquiry", getTextByXpath("//h1/span").trim());
99          assertElementPresentByLinkText("a1");
100         selectTopFrame();
101         waitAndClickByXpath("//div[@class='fancybox-item fancybox-close']");
102         selectFrameIframePortlet();
103         waitAndClickByXpath("//button[contains(text(),'Clear Values')]");
104 
105         //-----------------------------Code will not work as page has freemarker exceptions------------------------
106         Thread.sleep(2000);
107         waitAndClickByXpath("//*[@alt='Direct Inquiry']");
108         Alert a1 = driver.switchTo().alert();
109         Assert.assertEquals("Please enter a value in the appropriate field.", a1.getText());
110         a1.accept();
111         switchToWindow("null");
112         selectFrameIframePortlet();
113 
114         //No Direct Inquiry Option for Fiscal Officer.
115         waitAndTypeByName(CRITERIA_NAME+"[foId]", "1");
116         waitAndClickByXpath("//*[@id='u229']");
117         selectTopFrame();
118         Thread.sleep(5000);
119         WebElement iframe2 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
120         driver.switchTo().frame(iframe2);
121         Assert.assertEquals("Fiscal Officer Lookup", getTextByXpath("//h1/span").trim());
122         Assert.assertEquals("1", waitAndGetAttributeByName(CRITERIA_NAME + "[id]", "value"));
123         waitAndClickByXpath(SEARCH_BUTTON_XPATH);
124         selectFrameIframePortlet();
125         selectOptionByName(CRITERIA_NAME+"[extension.accountTypeCode]", "CAT");
126         waitAndClickByXpath("//fieldset[@id='u232_fieldset']/input[@alt='Search Field']");
127         selectTopFrame();
128         Thread.sleep(5000);
129         WebElement iframe3 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
130         driver.switchTo().frame(iframe3);
131         Assert.assertEquals("Travel Account Type Lookup", getTextByXpath("//h1/span").trim());
132         Assert.assertEquals("CAT", waitAndGetAttributeByName(CRITERIA_NAME + "[accountTypeCode]", "value"));
133         waitAndClickByXpath(SEARCH_BUTTON_XPATH);
134         selectFrameIframePortlet();
135     }
136 }