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 DemoLibraryWidgetsSuggestSmokeTest extends DemoLibraryBase {
026
027 /**
028 * /kr-krad/kradsampleapp?viewId=Demo-Suggest-View&methodToCall=start
029 */
030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Suggest-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 waitAndClickById("Demo-LibraryLink", "");
040 waitAndClickByLinkText("Widgets");
041 waitAndClickByLinkText("Suggest");
042 }
043
044 protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
045 String result) throws Exception {
046
047 //go to correct example
048 waitAndClickByLinkText(exampleLink);
049
050 //enter value
051 waitAndTypeByName(inputFieldName, search);
052
053 //verify expect suggest results
054 waitForElementPresent(By.linkText(result), "Library Widget Suggest, CAT not suggested");
055 assertElementPresentByLinkText(result);
056 waitAndClickByLinkText(result);
057
058 //verify text is populated
059 if (!driver.findElement(By.name(inputFieldName)).getAttribute("value").equals(result)) {
060 fail("input text is incorrect");
061 }
062
063 }
064
065 protected void testWidgetsSuggestHelperMethod2() throws Exception {
066
067 final String EXAMPLE_LINK_NAME = "View Helper Method Configuration 2";
068 final String INPUT_FIELD_NAME = "inputField4";
069 final String SEARCH_VALUE = "a";
070 final String RESULT = "a6";
071
072 //go to correct example
073 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
074
075 //enter values
076 waitAndTypeByName("inputField3", "a6-sub");
077 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
078
079 //verify expect suggest results
080 assertElementPresentByLinkText(RESULT);
081 waitAndClickByLinkText(RESULT);
082
083 //verify text is populated
084 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals(RESULT)) {
085 fail("input text is incorrect");
086 }
087 }
088
089 protected void testWidgetsSuggestRichText() throws Exception {
090
091 final String EXAMPLE_LINK_NAME = "Rich suggest options";
092 final String INPUT_FIELD_NAME = "inputField8";
093 final String SEARCH_VALUE = "r";
094
095 //go to correct example
096 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
097
098 //enter values
099 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