001    /**
002     * Copyright 2005-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/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.admin.test;
017    
018    import static org.junit.Assert.assertEquals;
019    import static org.junit.Assert.assertTrue;
020    
021    import org.junit.After;
022    import org.junit.Before;
023    import org.junit.Test;
024    
025    import com.thoughtworks.selenium.DefaultSelenium;
026    import com.thoughtworks.selenium.Selenium;
027    
028    /**
029     * TODO Administrator don't forget to fill this in. 
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     */
033    public class LocationPostCodeBlanketAppIT {
034        private Selenium selenium;
035        @Before
036        public void setUp() throws Exception {
037            selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
038            selenium.start();
039        }
040    
041        @Test
042        public void testPostalCode() throws Exception {
043            selenium.open(System.getProperty("remote.public.url"));
044            assertEquals("Login", selenium.getTitle());
045            selenium.type("__login_user", "admin");
046            selenium.click("//input[@value='Login']");
047            selenium.waitForPageToLoad("30000");
048            assertEquals("Kuali Portal Index", selenium.getTitle());
049            selenium.click("link=Administration");
050            selenium.waitForPageToLoad("30000");
051            assertEquals("Kuali Portal Index", selenium.getTitle());
052            selenium.click("link=Postal Code");
053            selenium.waitForPageToLoad("30000");
054            assertEquals("Kuali Portal Index", selenium.getTitle());
055            selenium.selectFrame("iframeportlet");
056            selenium.click("//img[@alt='create new']");
057            selenium.waitForPageToLoad("30000");
058            String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
059            assertTrue(selenium.isElementPresent("methodToCall.cancel"));
060            selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test Postal Code");        
061            selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + System.getProperty("remote.public.url") + "kr/lookup.do;::::).anchor4");
062            selenium.waitForPageToLoad("30000");
063            selenium.type("code", "US");
064            selenium.click("//input[@name='methodToCall.search' and @value='search']");
065            selenium.waitForPageToLoad("30000");
066            selenium.click("link=return value");
067            selenium.waitForPageToLoad("30000");
068            selenium.type("//input[@id='document.newMaintainableObject.code']", "PC1");
069            selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + System.getProperty("remote.public.url") + "kr/lookup.do;::::).anchor4");
070            selenium.waitForPageToLoad("30000");
071            selenium.click("//input[@name='methodToCall.search' and @value='search']");
072            selenium.waitForPageToLoad("30000");
073            selenium.click("//table[@id='row']/tbody/tr[4]/td[1]/a");
074            selenium.waitForPageToLoad("30000");
075            selenium.type("//input[@id='document.newMaintainableObject.cityName']", "Validation Test Postal Code1");
076            selenium.click("methodToCall.blanketApprove");
077            selenium.waitForPageToLoad("30000");
078            selenium.selectWindow("null");
079            selenium.click("//img[@alt='doc search']");
080            selenium.waitForPageToLoad("30000");
081            assertEquals("Kuali Portal Index", selenium.getTitle());
082            selenium.selectFrame("iframeportlet");
083            selenium.click("//input[@name='methodToCall.search' and @value='search']");
084            selenium.waitForPageToLoad("30000");
085            docId= "link=" + docId;
086            
087            assertTrue(selenium.isElementPresent(docId));       
088            if(selenium.isElementPresent(docId)){            
089                assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
090            }else{
091                assertEquals(docId, selenium.getText("//table[@id='row']/tbody/tr[1]/td[1]"));            
092                assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
093            }
094        }
095    
096        @After
097        public void tearDown() throws Exception {
098            selenium.stop();
099        }
100    
101    }