001 /** 002 * Copyright 2005-2013 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.samplu.krad.demo.uif.library; 017 018 import org.junit.Test; 019 import org.openqa.selenium.By; 020 import org.openqa.selenium.WebElement; 021 022 /** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public class DemoLibraryWidgetsTooltipSmokeTest extends DemoLibraryBase { 026 027 /** 028 * /kr-krad/kradsampleapp?viewId=Demo-Tooltip-View&methodToCall=start 029 */ 030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Tooltip-View&methodToCall=start"; 031 032 @Override 033 protected String getBookmarkUrl() { 034 return BOOKMARK_URL; 035 } 036 037 @Override 038 protected void navigate() throws Exception { 039 navigateToLibraryDemo("Widgets", "Tooltip"); 040 } 041 042 protected void testWidgetsTooltipHover() throws Exception { 043 044 //hover label 045 Thread.sleep(1000); 046 fireMouseOverEvent(By.id("u100085_label")); 047 Thread.sleep(1000); 048 WebElement tooltipHoverLabel = driver.findElement(By.xpath("//div[@data-for=\"u100085_label\"]")).findElement( 049 By.className("jquerybubblepopup-innerHtml")); 050 if (!tooltipHoverLabel.isDisplayed()) { 051 fail("Tooltip help for label not displayed."); 052 } 053 if (!tooltipHoverLabel.getText().equals("Sample text for label tooltip")) { 054 fail("Incorrect inner html text for label tooltip hover."); 055 } 056 057 //hover control 058 fireMouseOverEvent(By.id("u100085_control")); 059 Thread.sleep(1000); 060 WebElement tooltipHoverControl = driver.findElement(By.xpath("//div[@data-for=\"u100085_control\"]")) 061 .findElement(By.className("jquerybubblepopup-innerHtml")); 062 if (!tooltipHoverControl.isDisplayed()) { 063 fail("Tooltip help for control not displayed."); 064 } 065 if (!tooltipHoverControl.getText().equals("This is a helpful tooltip about this field")) { 066 fail("Incorrect inner html text for tooltip hover control."); 067 } 068 } 069 070 protected void testWidgetsTooltipFocus() throws Exception { 071 waitAndClickByLinkText(">> Open Library Navigation"); 072 waitAndClickByLinkText("Suggest"); 073 waitAndClickByLinkText("Tooltip"); 074 select(By.id("Demo-LargeExampleDropdown_control"), "Tooltip On Focus"); 075 076 //focus label 077 fireMouseOverEvent(By.id("u100101_label")); 078 Thread.sleep(1000); 079 WebElement tooltipFocusLabel = driver.findElement(By.xpath("//div[@data-for=\"u100101_label\"]")).findElement( 080 By.className("jquerybubblepopup-innerHtml")); 081 if (!tooltipFocusLabel.isDisplayed()) { 082 fail("Tooltip help for label not displayed."); 083 } 084 if (!tooltipFocusLabel.getText().equals("Click on the text box for a tool tip")) { 085 fail("Incorrect inner html text for label focus tooltip."); 086 } 087 088 //focus control 089 waitAndClickById("u100101_control"); 090 Thread.sleep(1000); 091 WebElement tooltipFocusControl = driver.findElement(By.xpath("//div[@data-for=\"u100101_control\"]")) 092 .findElement(By.className("jquerybubblepopup-innerHtml")); 093 if (!tooltipFocusControl.isDisplayed()) { 094 fail("Tooltip help for control not displayed."); 095 } 096 if (!tooltipFocusControl.getText().equals("This tooltip appears when the field receives focus")) { 097 fail("Incorrect inner html text for tooltip focus control."); 098 } 099 } 100 101 @Test 102 public void testWidgetsTooltipBookmark() throws Exception { 103 testWidgetsTooltipHover(); 104 testWidgetsTooltipFocus(); 105 driver.close(); 106 passed(); 107 } 108 109 @Test 110 public void testWidgetsTooltipNav() throws Exception { 111 testWidgetsTooltipHover(); 112 testWidgetsTooltipFocus(); 113 driver.close(); 114 passed(); 115 } 116 }