001    /*
002     * Copyright 2006-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.travel.krad.test;
017    
018    import com.thoughtworks.selenium.DefaultSelenium;
019    import com.thoughtworks.selenium.Selenium;
020    import edu.samplu.common.UpgradedSeleniumITBase;
021    import org.junit.After;
022    import org.junit.Before;
023    import org.junit.Test;
024    
025    import static org.junit.Assert.assertEquals;
026    import static org.junit.Assert.assertTrue;
027    
028    /**
029     * tests whether the watermarks is work as expected even when they contain an apostrophe
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     */
033    public class WatermarkValidationIT extends UpgradedSeleniumITBase {
034        @Override
035        public String getTestUrl() {
036            return PORTAL;
037        }
038    
039        @Test
040        /**
041         * if watermarking is ok, the cancel link will bring up a confirmation if something was typed into a textbox i.e
042         * the scripts will be working ok
043         */
044        public void testWatermarking() throws Exception {
045    //        selenium.open(System.getProperty("remote.public.url"));
046    //              selenium.type("name=__login_user", "quickstart");
047    //              selenium.click("css=input[type=\"submit\"]");
048    //              selenium.waitForPageToLoad("100000");
049                    selenium.click("link=KRAD");
050                    selenium.waitForPageToLoad("50000");
051                    selenium.click("link=Uif Components (Kitchen Sink)");
052                    selenium.waitForPageToLoad("100000");
053    //        selenium.selectFrame("iframeportlet");
054            selenium.focus("id=u73_control");
055                    selenium.type("id=u73_control", "something");
056            selenium.focus("id=u103_control");
057            selenium.type("id=u103_control", "something else");
058            assertEquals("something", selenium.getValue("xpath=//*[@id=\"u73_control\"]"));
059                    selenium.chooseCancelOnNextConfirmation();
060            // 'cancel' link
061                    selenium.click("id=u29");
062                    assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
063        }
064    
065        public void clearText(String field) throws Exception {
066            selenium.focus(field);
067            selenium.type(field, "");  
068            Thread.sleep(100); 
069        }
070    }