View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.samplu.krad.demo.uif.library;
17  
18  import org.junit.Test;
19  import org.openqa.selenium.By;
20  import org.openqa.selenium.WebElement;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoLibraryWidgetsSuggestSmokeTest extends DemoLibraryBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-Suggest-View&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Suggest-View&methodToCall=start";
31  
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          navigateToLibraryDemo("Widgets", "Suggest");
40      }
41  
42      protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
43              String result) throws Exception {
44  
45          //go to correct example
46          waitAndClickByLinkText(exampleLink);
47  
48          //enter value
49          waitAndTypeByName(inputFieldName, search);
50  
51          //verify expect suggest results
52          waitForElementPresent(By.linkText(result), "Library Widget Suggest, CAT not suggested");
53          assertElementPresentByLinkText(result);
54          waitAndClickByLinkText(result);
55  
56          //verify text is populated
57          if (!driver.findElement(By.name(inputFieldName)).getAttribute("value").equals(result)) {
58              fail("input text is incorrect");
59          }
60  
61      }
62  
63      protected void testWidgetsSuggestHelperMethod2() throws Exception {
64  
65          final String EXAMPLE_LINK_NAME = "View Helper Method Configuration 2";
66          final String INPUT_FIELD_NAME = "inputField4";
67          final String SEARCH_VALUE = "a";
68          final String RESULT = "a6";
69  
70          //go to correct example
71          waitAndClickByLinkText(EXAMPLE_LINK_NAME);
72  
73          //enter values
74          waitAndTypeByName("inputField3", "a6-sub");
75          waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
76  
77          //verify expect suggest results
78          assertElementPresentByLinkText(RESULT);
79          waitAndClickByLinkText(RESULT);
80  
81          //verify text is populated
82          if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals(RESULT)) {
83              fail("input text is incorrect");
84          }
85      }
86  
87      protected void testWidgetsSuggestRichText() throws Exception {
88  
89          final String EXAMPLE_LINK_NAME = "Rich suggest options";
90          final String INPUT_FIELD_NAME = "inputField8";
91          final String SEARCH_VALUE = "r";
92  
93          //go to correct example
94          waitAndClickByLinkText(EXAMPLE_LINK_NAME);
95  
96          //enter values
97          waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
98  
99          //verify expect suggest results
100         WebElement resultLink = driver.findElement(By.partialLinkText("Rich Option 1"));
101         resultLink.click();
102 
103         //verify text is populated
104         if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals("r1")) {
105             fail("input text is incorrect");
106         }
107     }
108 
109     @Test
110     public void testWidgetsTooltipBookmark() throws Exception {
111         testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
112         testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
113         testWidgetsSuggestHelperMethod2();
114         testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
115         testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
116         testWidgetsSuggestRichText();
117         testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
118         testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
119         driver.close();
120         passed();
121     }
122 
123     @Test
124     public void testWidgetsTooltipNav() throws Exception {
125         testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
126         testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
127         testWidgetsSuggestHelperMethod2();
128         testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
129         testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
130         testWidgetsSuggestRichText();
131         testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
132         testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
133         driver.close();
134         passed();
135     }
136 }
137 
138