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 edu.sampleu.krad.configview; 017 018 import org.kuali.rice.testtools.common.JiraAwareFailable; 019 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 020 021 /** 022 * @author Kuali Rice Team (rice.collab@kuali.org) 023 */ 024 public abstract class HelpAftBase extends WebDriverLegacyITBase { 025 026 /** 027 * /kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page 028 */ 029 public static final String BOOKMARK_URL = "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page"; 030 031 @Override 032 protected String getBookmarkUrl() { 033 return BOOKMARK_URL; 034 } 035 036 protected void navigation() throws Exception { 037 waitAndClickKRAD(); 038 waitAndClickByXpath(CONFIGURATION_VIEW_XPATH); 039 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 040 waitAndClickByLinkText("Help"); 041 Thread.sleep(5000); 042 } 043 044 protected void testHelpNav(JiraAwareFailable failable) throws Exception { 045 navigation(); 046 testViewHelp(); 047 testPageHelp(); 048 testTooltipHelp(); 049 testDisplayOnlyTooltipHelp(); 050 testMissingTooltipHelp(); 051 passed(); 052 } 053 054 protected void testHelpBookmark(JiraAwareFailable failable) throws Exception { 055 testViewHelp(); 056 testPageHelp(); 057 testTooltipHelp(); 058 testDisplayOnlyTooltipHelp(); 059 testMissingTooltipHelp(); 060 passed(); 061 } 062 063 064 /** 065 * Test the tooltip and external help on the page 066 */ 067 protected void testPageHelp() throws Exception { 068 // test tooltip help 069 fireMouseOverEventByXpath("//a/span[@class='uif-headerText-span']"); 070 waitForTextPresent("Sample text for section help - tooltip help"); 071 072 // test external help 073 waitAndClickByXpath("//input[@alt='Help for Configuration Test View']"); 074 Thread.sleep(5000); 075 switchToWindow("Kuali Foundation"); 076 Thread.sleep(5000); 077 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 078 } 079 080 /** 081 * Test the tooltip help on the section and fields 082 */ 083 protected void testTooltipHelp() throws Exception { 084 // verify that no tooltips are displayed initially 085 if (isElementPresentByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")) { 086 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")); 087 } 088 089 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label left')]")) { 090 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]")); 091 } 092 093 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label right')]")) { 094 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]")); 095 } 096 097 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label top')]")) { 098 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]")); 099 } 100 101 if (isElementPresentByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")) { 102 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")); 103 } 104 105 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")) { 106 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")); 107 } 108 109 if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) { 110 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")); 111 } 112 113 if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")) { 114 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")); 115 } 116 117 if (isElementPresentByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")) { 118 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")); 119 } 120 121 if (isElementPresentByXpath("//td[contains(text(),'Sample text for check box help')]")) { 122 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]")); 123 } 124 125 // test tooltip help of section header 126 fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section1']/header/h3[@class='uif-headerText']"); 127 Thread.sleep(500); 128 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")); 129 130 // verify that no external help exist 131 assertFalse(isElementPresent("#ConfigurationTestView-Help-Section1 input.uif-helpImage")); 132 133 // test tooltip help of field with label to the left 134 fireMouseOverEventByXpath("//label[@id='field-label-left_label']"); 135 Thread.sleep(3000); 136 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]")); 137 138 // test tooltip help of field with label to the right 139 fireMouseOverEventByXpath("//label[@id='field-label-right_label']"); 140 Thread.sleep(3000); 141 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]")); 142 143 // test tooltip help of field with label to the top 144 fireMouseOverEventByXpath("//label[@id='field-label-top_label']"); 145 Thread.sleep(3000); 146 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]")); 147 148 // verify that standalone help with tooltip is not rendered 149 assertFalse(isElementPresentByXpath("//*[@id='standalone-help-not-rendered']")); 150 151 // test tooltip help when it overrides a tooltip 152 fireMouseOverEventByXpath("//label[@id='override-tooltip_label']"); 153 Thread.sleep(3000); 154 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")); 155 if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) { 156 assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")); 157 } 158 159 // test tooltip help in conjunction with a focus event tooltip 160 fireMouseOverEventByXpath("//input[@id='on-focus-tooltip_control']"); 161 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")); 162 fireMouseOverEventByXpath("//label[@id='on-focus-tooltip_label']"); 163 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")); 164 165 // test tooltip help against a check box - help contains html 166 fireMouseOverEventByXpath("//label[@id='checkbox_label']"); 167 assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]")); 168 } 169 170 /** 171 * Test the tooltip help on the sub-section and fields that are display only 172 */ 173 protected void testDisplayOnlyTooltipHelp() throws Exception { 174 175 // test tooltip help of sub-section header 176 fireMouseOverEventByXpath("//section[@data-parent='ConfigurationTestView-Help-Section1']/header/h4"); 177 waitForElementPresentByXpath("//td[contains(text(),'Sample text for sub-section help')]"); 178 179 // test tooltip help of display only data field 180 fireMouseOverEventByXpath("//label[@for='display-field_control']"); 181 waitForElementPresentByXpath("//td[contains(text(),'Sample text for read only field help')]"); 182 } 183 184 /** 185 * Test the tooltip help on the section and fields with no content 186 */ 187 protected void testMissingTooltipHelp() throws Exception { 188 189 // test tooltip help of section header 190 fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section2']/div"); 191 assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']")); 192 193 // test tooltip help of field 194 fireMouseOverEventByXpath("//label[@id='missing-tooltip-help_label']"); 195 assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']")); 196 } 197 198 /** 199 * Test the tooltip and external help on the view 200 */ 201 protected void testViewHelp() throws Exception { 202 // test tooltip help 203 fireEvent("field102", "blur"); 204 fireMouseOverEventByXpath("//label[@id='field-label-left_label']"); 205 waitForTextPresent("Sample text for field help - label left"); 206 207 // test external help 208 waitAndClickByXpath("//input[@alt='Help for Configuration Test View']"); 209 Thread.sleep(5000); 210 switchToWindow("Kuali Foundation"); 211 Thread.sleep(5000); 212 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 213 } 214 }