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