View Javadoc
1   /*
2    * Copyright 2006-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.travel.krad.test;
17  
18  import com.thoughtworks.selenium.DefaultSelenium;
19  import com.thoughtworks.selenium.Selenium;
20  import org.junit.After;
21  import org.junit.Before;
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertTrue;
26  
27  /**
28   *tests whether the watermarking is working ok
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class WatermarkValidation {
33      private Selenium selenium;
34  
35      @Before
36      public void setUp() throws Exception {
37          selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));//was http://localhost:8080/
38          selenium.start();
39      }
40  
41      @Test
42      /**
43       * if watermarking is ok, the cancel link will bring up a confirmation if something was typed into a textbox i.e
44       * the scripts will be working ok
45       */
46      public void testWatermarking() throws Exception {
47          selenium.open(System.getProperty("remote.public.url"));
48  		selenium.type("name=__login_user", "quickstart");
49  		selenium.click("css=input[type=\"submit\"]");
50  		selenium.waitForPageToLoad("100000");
51  		selenium.click("link=KRAD");
52  		selenium.waitForPageToLoad("50000");
53  		selenium.click("link=Uif Components (Kitchen Sink)");
54  		selenium.waitForPageToLoad("100000");
55          selenium.selectFrame("iframeportlet");
56  		//selenium.selectWindow("name=iframeportlet");
57          selenium.focus("id=257");
58  		selenium.type("id=257", "something");
59          selenium.focus("id=371");
60          selenium.type("id=371", "something else");
61          assertEquals("something", selenium.getValue("xpath=//*[@id=\"257\"]"));
62  		selenium.chooseCancelOnNextConfirmation();
63  		selenium.click("id=10");
64          //selenium.
65          //Thread.sleep(1000);
66  		assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
67      }
68  
69      @After
70      public void tearDown() throws Exception {
71          selenium.stop();
72      }
73      
74      public void clearText(String field) throws Exception {
75          selenium.focus(field);
76          selenium.type(field, "");  
77          Thread.sleep(100); 
78      }
79  }