View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.krad.compview;
18  
19  import com.thoughtworks.selenium.Selenium;
20  import junit.framework.Assert;
21  import org.junit.After;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.openqa.selenium.WebDriver;
25  import org.openqa.selenium.WebDriverBackedSelenium;
26  import org.openqa.selenium.firefox.FirefoxDriver;
27  
28  /**
29   * Selenium test that tests that tooltips are rendered on mouse over and focus events
30   * and hidden on mouse out and blur events
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class UifTooltipIT {
35      private Selenium selenium;
36  
37      @Before
38      public void setUp() throws Exception {
39          WebDriver driver = new FirefoxDriver();
40          String baseUrl = "http://localhost:8080/";
41          selenium = new WebDriverBackedSelenium(driver, baseUrl);
42      }
43  
44      @Test
45      public void testTooltip() throws Exception {
46          // open Other Examples page in kitchen sink view
47          selenium.open(
48                  "http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10");
49          selenium.type("name=__login_user", "admin");
50          selenium.click("//input[@value='Login']");
51          selenium.waitForPageToLoad("30000");
52          // check if tooltip opens on focus
53          selenium.fireEvent("name=field1", "focus");
54          Assert.assertTrue(selenium.isVisible(
55                  "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
56          // check if tooltip closed on blur
57          selenium.fireEvent("name=field1", "blur");
58          Assert.assertFalse(selenium.isVisible(
59                  "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
60          // check if tooltip opens on mouse over
61          selenium.mouseOver("name=field2");
62          Assert.assertTrue(selenium.isVisible(
63                  "//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
64          // check if tooltip closed on mouse out
65          selenium.mouseOut("name=field2");
66          Assert.assertFalse(selenium.isVisible(
67                  "//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
68          // check that default tooltip does not display when there are an error message on the field
69          selenium.type("name=field1", "1");
70          selenium.fireEvent("name=field1", "blur");
71          selenium.fireEvent("name=field1", "focus");
72          Assert.assertFalse(selenium.isVisible(
73                  "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
74      }
75  
76      @After
77      public void tearDown() throws Exception {
78          selenium.stop();
79      }
80  
81  }