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