001 /** 002 * Copyright 2005-2014 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 org.kuali.rice.krad.labs.kitchensink; 017 018 import org.kuali.rice.testtools.common.JiraAwareFailable; 019 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 020 import org.openqa.selenium.By; 021 022 /** 023 * Tests the Component section in Rice. 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 public abstract class UifTooltipAftBase extends LabsKitchenSinkBase { 028 029 /** 030 * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10 031 */ 032 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10"; 033 034 private static final String NAME_FIELD_1 = "field1"; 035 private static final String NAME_FIELD_2 = "field2"; 036 037 @Override 038 protected String getBookmarkUrl() { 039 return BOOKMARK_URL; 040 } 041 042 protected void navigation() throws Exception { 043 navigateToKitchenSink("Other Examples"); 044 } 045 046 protected void testUifTooltipByName(String nameField1, String nameField2) throws Exception { 047 findElement(By.name(nameField2)); // fields must be in view for tooltips to be displayed 048 049 // check if tooltip opens on focus 050 fireEvent(nameField1, "focus"); 051 fireMouseOverEventByName(nameField1); 052 053 String tooltipContents = getText(By.cssSelector("[data-for='ucbjiy8_control']")); 054 assertEquals("This tooltip is triggered by focus or and mouse over.", tooltipContents); 055 fireEvent(nameField1, "blur"); 056 057 fireEvent(nameField2, "focus"); 058 Thread.sleep(5000); 059 060 // check if tooltip opens on mouse over 061 fireMouseOverEventByName(nameField2); 062 assertFalse("unable to detect tooltip", isVisibleByXpath("//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 063 064 // check if tooltip closed on mouse out of nameField2 065 fireEvent(nameField2, "blur"); 066 fireMouseOverEventByName(nameField1); 067 waitAndTypeByName(nameField1, ""); 068 Thread.sleep(5000); 069 assertFalse("able to detect tooltip", isVisibleByXpath( 070 "//td[contains(.,\"This is a tool-tip with different position and tail options\")]")); 071 072 // check that default tooltip does not display when there are an error message on the field 073 waitAndTypeByName(nameField1, "1"); 074 fireEvent(nameField1, "blur"); 075 fireMouseOverEventByName(nameField1); 076 Thread.sleep(10000); 077 } 078 079 protected void testUifTooltipNav(JiraAwareFailable failable) throws Exception { 080 navigation(); 081 testUifTooltipByName(NAME_FIELD_1, NAME_FIELD_2); 082 passed(); 083 } 084 085 protected void testUifTooltipBookmark(JiraAwareFailable failable) throws Exception { 086 testUifTooltipByName(NAME_FIELD_1, NAME_FIELD_2); 087 passed(); 088 } 089 }