View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.library.widgets;
17  
18  import org.junit.Test;
19  import org.kuali.rice.krad.demo.uif.library.DemoLibraryBase;
20  import org.openqa.selenium.By;
21  import org.openqa.selenium.WebElement;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DemoWidgetsHelpAft extends DemoLibraryBase {
27  
28      /**
29       * /kr-krad/kradsampleapp?viewId=Demo-HelpView&methodToCall=start
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-HelpView&methodToCall=start";
32  
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      @Override
39      protected void navigate() throws Exception {
40          navigateToLibraryDemo("Widgets", "Help");
41      }
42  
43      protected void testWidgetsTooltipHelp() throws Exception {
44          fireMouseOverEvent(By.id("Demo-Help-Field1_label"));
45          WebElement helpExample1 = driver.findElement(By.xpath("//div[@data-for=\"Demo-Help-Field1_label\"]"))
46                  .findElement(By.className("jquerybubblepopup-innerHtml"));
47          if (!helpExample1.isDisplayed()) {
48              fail("Example 1 help not displayed.");
49          }
50          if (!helpExample1.getText().equals("Sample text for field help - label left")) {
51              fail("Incorrect inner html text. Actual text: " + helpExample1.getText());
52          }
53      }
54      
55      protected void testMissingTooltipHelp() throws Exception {
56         selectByName("exampleShown","Missing Tooltip Help");
57         fireEvent("dataField1", "focus");
58         waitForElementNotPresent(By.xpath("//div[@class='jquerybubblepopup-innerHtml']"));
59      }
60      
61      protected void testExternalHelp() throws Exception {
62      	selectByName("exampleShown","External Help");
63      	waitForElementPresentByXpath("//input[@type='image' and @title='Help for Field Label']");
64      	waitForElementPresentByXpath("//input[@type='image' and @title='Help']");
65      	waitForElementPresentByXpath("//input[@type='image' and @title='Help for Display only fields']");
66      }
67      
68      private void testAllHelp() throws Exception {
69      	testWidgetsTooltipHelp();
70          testMissingTooltipHelp();
71  	    testExternalHelp();
72  	    passed();
73      }
74  
75      @Test
76      public void testWidgetsHelpBookmark() throws Exception {
77      	testAllHelp();
78      }
79  
80      @Test
81      public void testWidgetsHelpNav() throws Exception {
82      	testAllHelp();
83      }
84  }