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