001    /*
002     * Copyright 2011 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/ecl1.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 static org.junit.Assert.*;
019    
020    import org.junit.Test;
021    import org.openqa.selenium.Alert;
022    import org.openqa.selenium.By;
023    import org.openqa.selenium.WebElement;
024    
025    import edu.samplu.common.ITUtil;
026    import edu.samplu.common.WebDriverLegacyITBase;
027    
028    /**
029     * it tests travel account lookup screen.
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     */
033    public class TravelAccountLookupLegacyIT extends WebDriverLegacyITBase {
034        @Override
035        public String getTestUrl() {
036            return ITUtil.PORTAL;
037        }
038        
039        @Test
040        public void testTravelAccountLookup() throws Exception {
041            waitAndClickByLinkText("KRAD");
042            waitAndClickByLinkText("Travel Account Lookup");
043            selectFrame("iframeportlet");
044            
045            //Blank Search
046            waitAndClickByXpath("//*[@id='u18']");
047            Thread.sleep(2000);
048            assertElementPresentByLinkText("a1");
049            assertElementPresentByLinkText("a2");
050            assertElementPresentByLinkText("a3");
051            
052            //QuickFinder Lookup
053            
054            waitAndTypeByName("lookupCriteria[number]", "a*");
055            waitAndClickByXpath("//*[@id='u18']");
056            Thread.sleep(2000);
057            assertElementPresentByLinkText("a1");
058            assertElementPresentByLinkText("a2");
059            assertElementPresentByLinkText("a3");
060            waitAndClickByXpath("//button[@id='u19']");
061            Thread.sleep(2000);
062            
063            //search with each field
064            waitAndTypeByName("lookupCriteria[number]", "a2");
065            waitAndClickByXpath("//*[@id='u18']");
066            Thread.sleep(2000);
067            assertElementPresentByLinkText("a2");
068            waitAndClickByXpath("//button[@id='u19']");
069            Thread.sleep(2000);
070            
071            waitAndTypeByName("lookupCriteria[foId]", "1");
072            waitAndClickByXpath("//*[@id='u18']");
073            Thread.sleep(2000);
074            assertEquals("1", getTextByXpath("//table[@id='u27']//tr//td[8]").trim().substring(0, 1));
075            waitAndClickByXpath("//button[@id='u19']");
076            Thread.sleep(2000);
077            
078            selectOptionByName("lookupCriteria[extension.accountTypeCode]", "CAT");
079            waitAndClickByXpath("//*[@id='u18']");
080            waitAndClickByXpath("//table[@id='u27']//tr//td[2]//a");
081            Thread.sleep(2000);
082            selectTopFrame();
083            Thread.sleep(5000);
084            WebElement iframe1= driver.findElement(By.xpath("//iframe[@class='fancybox-iframe']"));
085            driver.switchTo().frame(iframe1);
086            assertEquals("Travel Account Inquiry", getTextByXpath("//h1/span").trim());
087            assertEquals("CAT - Clearing Account Type", getTextByXpath("//*[@id='u44_control']").trim());
088            waitAndClickByXpath("//button[@id='u13']");
089            selectFrame("iframeportlet");
090           
091        }
092    }