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.samplu.travel.krad.test; 017 018 import org.kuali.rice.testtools.selenium.Failable; 019 import org.kuali.rice.testtools.selenium.ITUtil; 020 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 021 022 import org.junit.Assert; 023 import org.openqa.selenium.Alert; 024 import org.openqa.selenium.By; 025 import org.openqa.selenium.WebElement; 026 027 import com.thoughtworks.selenium.SeleneseTestBase; 028 029 /** 030 * Tests the Component section in Rice. 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034 public abstract class InquiryAbstractSmokeTestBase extends WebDriverLegacyITBase { 035 036 /** 037 * ITUtil.PORTAL + "?channelTitle=Travel%20Account%20Lookup&channelUrl=" 038 * + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD 039 * +"edu.sampleu.travel.bo.TravelAccount&returnLocation=" 040 * + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS 041 */ 042 public static final String BOOKMARK_URL = ITUtil.PORTAL 043 + "?channelTitle=Travel%20Account%20Lookup&channelUrl=" 044 + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD 045 + "edu.sampleu.travel.bo.TravelAccount" 046 + "&returnLocation=" + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK + ITUtil.SHOW_MAINTENANCE_LINKS; 047 048 /** 049 * //*[contains(button,"Search")]/button 050 */ 051 public static final String SEARCH_BUTTON_XPATH ="//div[contains(button, 'Search')]/button[3]"; 052 053 /** 054 * lookupCriteria 055 */ 056 public static final String CRITERIA_NAME="lookupCriteria"; 057 058 /** 059 * //iframe[@class='fancybox-iframe'] 060 */ 061 public static final String FANCYBOX_IFRAME_XPATH="//iframe[@class='fancybox-iframe']"; 062 063 /** 064 * Nav tests start at {@link org.kuali.rice.testtools.selenium.ITUtil#PORTAL}. Bookmark Tests should override and return {@link TravelAccountTypeLookupAbstractSmokeTestBase#BOOKMARK_URL} 065 * {@inheritDoc} 066 * @return 067 */ 068 @Override 069 public String getTestUrl() { 070 return ITUtil.PORTAL; 071 } 072 073 protected void navigation() throws Exception { 074 waitAndClickKRAD(); 075 //waitAndClickByLinkText(TRAVEL_ACCOUNT_LOOKUP_LINK_TEXT); 076 waitAndClickByXpath("(//a[contains(text(),'Travel Account Lookup')])[3]"); 077 } 078 079 protected void testInquiryNav(Failable failable) throws Exception { 080 navigation(); 081 testInquiry(); 082 passed(); 083 } 084 085 protected void testInquiryBookmark(Failable failable) throws Exception { 086 testInquiry(); 087 passed(); 088 } 089 090 protected void testInquiry() throws Exception { 091 selectFrameIframePortlet(); 092 waitAndTypeByName(CRITERIA_NAME+"[number]", "a1"); 093 waitAndClickByXpath("//*[@alt='Direct Inquiry']"); 094 selectTopFrame(); 095 Thread.sleep(5000); 096 WebElement iframe1 = driver.findElement(By.xpath(FANCYBOX_IFRAME_XPATH)); 097 driver.switchTo().frame(iframe1); 098 SeleneseTestBase.assertEquals("Travel Account Inquiry", getTextByXpath("//h1/span").trim()); 099 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 }