001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.travel;
017
018 import com.thoughtworks.selenium.SeleneseTestBase;
019 import org.junit.Assert;
020 import org.kuali.rice.testtools.common.JiraAwareFailable;
021 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
022 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
023 import org.kuali.rice.testtools.selenium.WebDriverUtils;
024 import org.openqa.selenium.Alert;
025 import org.openqa.selenium.By;
026 import org.openqa.selenium.WebElement;
027
028 /**
029 * Tests the Component section in Rice.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033 public abstract class InquiryAftBase extends WebDriverLegacyITBase {
034
035 /**
036 * ITUtil.PORTAL + "?channelTitle=Travel%20Account%20Lookup&channelUrl="
037 * + WebDriverUtils.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
038 * +"edu.sampleu.travel.bo.TravelAccount&returnLocation="
039 * + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS
040 */
041 public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL
042 + "?channelTitle=Travel%20Account%20Lookup&channelUrl="
043 + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
044 + "edu.sampleu.travel.bo.TravelAccount"
045 + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS;
046
047 /**
048 * //*[contains(button,"Search")]/button
049 */
050 public static final String SEARCH_BUTTON_XPATH ="//div[contains(button, 'Search')]/button[3]";
051
052 /**
053 * lookupCriteria
054 */
055 public static final String CRITERIA_NAME="lookupCriteria";
056
057 /**
058 * //iframe[@class='fancybox-iframe']
059 */
060 public static final String FANCYBOX_IFRAME_XPATH="//iframe[@class='fancybox-iframe']";
061
062 protected void navigation() throws Exception {
063 waitAndClickKRAD();
064 //waitAndClickByLinkText(TRAVEL_ACCOUNT_LOOKUP_LINK_TEXT);
065 waitAndClickByXpath("(//a[contains(text(),'Travel Account Lookup')])[3]");
066 }
067
068 protected void testInquiryNav(JiraAwareFailable failable) throws Exception {
069 navigation();
070 testInquiry();
071 passed();
072 }
073
074 protected void testInquiryBookmark(JiraAwareFailable failable) throws Exception {
075 testInquiry();
076 passed();
077 }
078
079 protected void testInquiry() throws Exception {
080 selectFrameIframePortlet();
081 waitAndTypeByName(CRITERIA_NAME+"[number]", "a1");
082 waitAndClickByXpath("//*[@alt='Direct Inquiry']");
083 selectTopFrame();
084 Thread.sleep(5000);
085 WebElement iframe1 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH));
086 driver.switchTo().frame(iframe1);
087 SeleneseTestBase.assertEquals("Travel Account Inquiry", getTextByXpath("//h1/span").trim());
088 assertElementPresentByLinkText("a1");
089 selectTopFrame();
090 waitAndClickByXpath("//div[@class='fancybox-item fancybox-close']");
091 selectFrameIframePortlet();
092 waitAndClickByXpath("//button[contains(text(),'Clear Values')]");
093
094 //-----------------------------Code will not work as page has freemarker exceptions------------------------
095 Thread.sleep(2000);
096 waitAndClickByXpath("//*[@alt='Direct Inquiry']");
097 Alert a1 = driver.switchTo().alert();
098 Assert.assertEquals("Please enter a value in the appropriate field.", a1.getText());
099 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 }