1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.widgets;
17
18 import org.junit.Ignore;
19 import org.junit.Test;
20 import org.kuali.rice.krad.demo.uif.library.LibraryBase;
21 import org.openqa.selenium.By;
22 import org.openqa.selenium.WebElement;
23
24
25
26
27 public class LibraryWidgetsSuggestAft extends LibraryBase {
28
29
30
31
32 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-SuggestView&methodToCall=start";
33
34 @Override
35 protected String getBookmarkUrl() {
36 return BOOKMARK_URL;
37 }
38
39 @Override
40 protected void navigate() throws Exception {
41 navigateToLibraryDemo("Widgets", "Suggest");
42 }
43
44
45 protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
46 String result) throws Exception {
47
48
49 waitAndClickByLinkText(exampleLink);
50
51
52 waitAndTypeByName(inputFieldName, search);
53
54
55 waitForElementPresent(By.linkText(result), "Library Widget Suggest, " + result + " not suggested");
56 waitAndClickByLinkText(result);
57
58
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 = "a2";
71
72
73 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
74
75
76 waitAndTypeByName("inputField3", "SUB1");
77 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
78
79
80 assertElementPresentByLinkText(RESULT);
81 waitAndClickByLinkText(RESULT);
82
83
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 testWidgetsSuggestValidationHelperMethod() throws Exception {
90 final String EXAMPLE_LINK_NAME = "Service Method and Sorting Configuration";
91 final String INPUT_FIELD_NAME = "inputField6";
92 final String invalidSearch = "Travel Account 10";
93 final String validSearch = "Travel Account 2";
94
95 waitAndClickLinkContainingText(EXAMPLE_LINK_NAME);
96
97 assertFocusTypeBlurError(INPUT_FIELD_NAME, invalidSearch);
98 assertFocusTypeBlurValid(INPUT_FIELD_NAME, validSearch);
99 }
100
101 protected void testWidgetsSuggestRichText() throws Exception {
102
103 final String EXAMPLE_LINK_NAME = "Rich suggest options";
104 final String INPUT_FIELD_NAME = "inputField8";
105 final String SEARCH_VALUE = "r";
106
107
108 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
109
110
111 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
112
113
114 WebElement resultLink = driver.findElement(By.partialLinkText("Rich Option 1"));
115 resultLink.click();
116
117
118 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals("r1")) {
119 fail("input text is incorrect");
120 }
121 }
122
123 protected void testTooltips() throws Exception {
124 testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
125 testWidgetsSuggestHelperMethod2();
126 testWidgetsSuggestValidationHelperMethod();
127 testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
128 testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
129 }
130
131 @Test
132 public void testWidgetsTooltipBookmark() throws Exception {
133 testTooltips();
134 passed();
135 }
136
137 @Test
138 public void testWidgetsTooltipAutoQueryBookmark() throws Exception {
139 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
140 passed();
141 }
142
143 @Test
144 public void testWidgetsTooltipCustomSelectionBookmark() throws Exception {
145 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
146 passed();
147 }
148
149 @Test
150 public void testWidgetsTooltipRichTextBookmark() throws Exception {
151 testWidgetsSuggestRichText();
152 passed();
153 }
154
155 @Test
156 public void testWidgetsTooltipServiceSortingBookmark() throws Exception {
157 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "Tr", "Travel Account 1");
158 passed();
159 }
160
161 @Test
162 public void testWidgetsTooltipNav() throws Exception {
163 testTooltips();
164 passed();
165 }
166
167 @Test
168 public void testWidgetsTooltipAutoQueryNav() throws Exception {
169 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
170 passed();
171 }
172
173 @Test
174 public void testWidgetsTooltipCustomSelectionNav() throws Exception {
175 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
176 passed();
177 }
178
179 @Test
180 public void testWidgetsTooltipRichTextNav() throws Exception {
181 testWidgetsSuggestRichText();
182 passed();
183 }
184
185 @Test
186 public void testWidgetsTooltipServiceSortingNav() throws Exception {
187 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "Tr", "Travel Account 1");
188 passed();
189 }
190 }
191
192