001 /* 002 * Copyright 2006-2012 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 017 package edu.samplu.krad.compview; 018 019 import com.thoughtworks.selenium.Selenium; 020 import junit.framework.Assert; 021 import org.junit.After; 022 import org.junit.Before; 023 import org.junit.Test; 024 import org.openqa.selenium.WebDriver; 025 import org.openqa.selenium.WebDriverBackedSelenium; 026 import org.openqa.selenium.firefox.FirefoxDriver; 027 028 /** 029 * Selenium test that tests that tooltips are rendered on mouse over and focus events 030 * and hidden on mouse out and blur events 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034 public class UifTooltipIT { 035 private Selenium selenium; 036 037 @Before 038 public void setUp() throws Exception { 039 WebDriver driver = new FirefoxDriver(); 040 String baseUrl = "http://localhost:8080/"; 041 selenium = new WebDriverBackedSelenium(driver, baseUrl); 042 } 043 044 @Test 045 public void testTooltip() throws Exception { 046 // open Other Examples page in kitchen sink view 047 selenium.open( 048 "http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10"); 049 selenium.type("name=__login_user", "admin"); 050 selenium.click("//input[@value='Login']"); 051 selenium.waitForPageToLoad("30000"); 052 // check if tooltip opens on focus 053 selenium.fireEvent("name=field1", "focus"); 054 Assert.assertTrue(selenium.isVisible( 055 "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]")); 056 // check if tooltip closed on blur 057 selenium.fireEvent("name=field1", "blur"); 058 Assert.assertFalse(selenium.isVisible( 059 "//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]")); 060 // check if tooltip opens on mouse over 061 selenium.mouseOver("name=field2"); 062 Assert.assertTrue(selenium.isVisible( 063 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 064 // check if tooltip closed on mouse out 065 selenium.mouseOut("name=field2"); 066 Assert.assertFalse(selenium.isVisible( 067 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 068 } 069 070 @After 071 public void tearDown() throws Exception { 072 selenium.stop(); 073 } 074 075 }