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 org.junit.After;
021 import org.junit.Before;
022 import org.junit.Test;
023
024 import static org.junit.Assert.assertEquals;
025 import static org.junit.Assert.assertTrue;
026
027 /**
028 *tests whether the watermarking is working ok
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class WatermarkValidation {
033 private Selenium selenium;
034
035 @Before
036 public void setUp() throws Exception {
037 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));//was http://localhost:8080/
038 selenium.start();
039 }
040
041 @Test
042 /**
043 * if watermarking is ok, the cancel link will bring up a confirmation if something was typed into a textbox i.e
044 * the scripts will be working ok
045 */
046 public void testWatermarking() throws Exception {
047 selenium.open(System.getProperty("remote.public.url"));
048 selenium.type("name=__login_user", "quickstart");
049 selenium.click("css=input[type=\"submit\"]");
050 selenium.waitForPageToLoad("100000");
051 selenium.click("link=KRAD");
052 selenium.waitForPageToLoad("50000");
053 selenium.click("link=Uif Components (Kitchen Sink)");
054 selenium.waitForPageToLoad("100000");
055 selenium.selectFrame("iframeportlet");
056 //selenium.selectWindow("name=iframeportlet");
057 selenium.focus("id=257");
058 selenium.type("id=257", "something");
059 selenium.focus("id=371");
060 selenium.type("id=371", "something else");
061 assertEquals("something", selenium.getValue("xpath=//*[@id=\"257\"]"));
062 selenium.chooseCancelOnNextConfirmation();
063 selenium.click("id=10");
064 //selenium.
065 //Thread.sleep(1000);
066 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
067 }
068
069 @After
070 public void tearDown() throws Exception {
071 selenium.stop();
072 }
073
074 public void clearText(String field) throws Exception {
075 selenium.focus(field);
076 selenium.type(field, "");
077 Thread.sleep(100);
078 }
079 }