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          waitAndClickById("Demo-LibraryLink", "");
40          waitAndClickByLinkText("Widgets");
41          waitAndClickByLinkText("Suggest");
42      }
43  
44      protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
45              String result) throws Exception {
46  
47          //go to correct example
48          waitAndClickByLinkText(exampleLink);
49  
50          //enter value
51          waitAndTypeByName(inputFieldName, search);
52  
53          //verify expect suggest results
54          waitForElementPresent(By.linkText(result), "Library Widget Suggest, CAT not suggested");
55          assertElementPresentByLinkText(result);
56          waitAndClickByLinkText(result);
57  
58          //verify text is populated
59          if (!driver.findElement(By.name(inputFieldName)).getAttribute("value").equals(result)) {
60              fail("input text is incorrect");
61          }
62  
63      }
64  
65      protected void testWidgetsSuggestHelperMethod2() throws Exception {
66  
67          final String EXAMPLE_LINK_NAME = "View Helper Method Configuration 2";
68          final String INPUT_FIELD_NAME = "inputField4";
69          final String SEARCH_VALUE = "a";
70          final String RESULT = "a6";
71  
72          //go to correct example
73          waitAndClickByLinkText(EXAMPLE_LINK_NAME);
74  
75          //enter values
76          waitAndTypeByName("inputField3", "a6-sub");
77          waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
78  
79          //verify expect suggest results
80          assertElementPresentByLinkText(RESULT);
81          waitAndClickByLinkText(RESULT);
82  
83          //verify text is populated
84          if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals(RESULT)) {
85              fail("input text is incorrect");
86          }
87      }
88  
89      protected void testWidgetsSuggestRichText() throws Exception {
90  
91          final String EXAMPLE_LINK_NAME = "Rich suggest options";
92          final String INPUT_FIELD_NAME = "inputField8";
93          final String SEARCH_VALUE = "r";
94  
95          //go to correct example
96          waitAndClickByLinkText(EXAMPLE_LINK_NAME);
97  
98          //enter values
99          waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
100 
101         //verify expect suggest results
102         WebElement resultLink = driver.findElement(By.partialLinkText("Rich Option 1"));
103         resultLink.click();
104 
105         //verify text is populated
106         if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals("r1")) {
107             fail("input text is incorrect");
108         }
109     }
110 
111     @Test
112     public void testWidgetsTooltipBookmark() throws Exception {
113         testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
114         testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
115         testWidgetsSuggestHelperMethod2();
116         testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
117         testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
118         testWidgetsSuggestRichText();
119         testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
120         testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
121         driver.close();
122         passed();
123     }
124 
125     @Test
126     public void testWidgetsTooltipNav() throws Exception {
127         testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
128         testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
129         testWidgetsSuggestHelperMethod2();
130         testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
131         testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
132         testWidgetsSuggestRichText();
133         testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
134         testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
135         driver.close();
136         passed();
137     }
138 }
139 
140