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 watermarks is work as expected even when they contain an apostrophe
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class WatermarkValidationIT {
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.focus("id=u73_control");
57  		selenium.type("id=u73_control", "something");
58          selenium.focus("id=u103_control");
59          selenium.type("id=u103_control", "something else");
60          assertEquals("something", selenium.getValue("xpath=//*[@id=\"u73_control\"]"));
61  		selenium.chooseCancelOnNextConfirmation();
62          // 'cancel' link
63  		selenium.click("id=u29");
64  		assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
65      }
66  
67      @After
68      public void tearDown() throws Exception {
69          selenium.stop();
70      }
71      
72      public void clearText(String field) throws Exception {
73          selenium.focus(field);
74          selenium.type(field, "");  
75          Thread.sleep(100); 
76      }
77  }